I have this code:
$people=array();
$i=0;
foreach ($xml->xpath('//person') as $character) {
if ($character->status!="Active"){
$people[$i]['fullname']=(string)$character->fullname;
$people[$i]['status']=(string)$character->status;
$i++;
}
}
It creates an array with numeric keys, based on the value of $i. However, I don't actually want that, I want the "fullname" string to be the key but I can't work out how to dynamically assign the key. I was trying things like:
$people[(string)$character->fullname]=>(string)$character->status;
but this just throws errors. I can't work out how to create keys based on variables. Can anyone help, please?
(string)casts.=>to=.