php - How do I push key/value to array -
i have data trying push array (key/value)
my code below when try , print array, empty.
what missing?
$dataarray = array(); foreach($datatypes $data) { $dataarray[$data->dataid] .= $data->type; } print_r($dataarray);
edit
this $datatypes looks like.
simplexmlelement object ( [dataid] => 1 [type] => account number [description] => user account number [whoadded] => carl [whenadded] => 2014-05-14t00:00:00 )
solution due being xml, had cast vars int , string
$dataarray[(int)$data->dataid] = (string)$data->type;
try with:
$dataarray = array(); foreach($datatypes $data) { $dataarray[$data->dataid] = $data->type; } print_r($dataarray);
Comments
Post a Comment