php - How to insert an array to an array -


i add array within existing array. tryin use array_push works long dont try assign key array (if try add key syntax error... :-()

this initial array:

$resultarray = array(     "transactiondate" => "$transactiondate",       "tx"=>array(         "0"=>array(             "txindex" => "$txindex",              "value" => "$value",               "paymentconfirmedcount" => "$paymentconfirmedcount"         ),         "1"=>array(             "txindex" => "$txindex",              "value" => "$value",               "paymentconfirmedcount" => "$paymentconfirmedcount"         )      )   ); 

i add:

$arraytoadd = array(     "0"=>array(         "txindex" => "$txindex",          "value" => "$value",           "paymentconfirmedcount" =>          "$paymentconfirmedcount"     ) ); 

if try:

array_push($resultarray->tx, $arraytoadd);  

but not work , results in warning of "array_push() [function.array-push]: first argument should array"

if try :

array_push($resultarray, $arraytoadd);  

it adds array not $resultarray->tx

any suggestions welcomed!

you have access element in array $resultarray["tx"] , not $resultarray->tx. second 1 access members in php class. an

array_push($resultarray["tx"], $arraytoadd); 

should work.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -