Why the array is formed thus?

proper array form this way
$arrInsert[]=$innerArr;
foreach (listВiv as $div)
{
$innerArr=array();
 if (is_object($div->adress))
{
$innerArr['adress']=$adress->text;
}
 if (is_object($div->codes))
{
 foreach ($div->codes->children as $child){
 $arrExpl=explode(': ', $child->text);
$coneNames=($arrExpl[0]=='bin')?'ogrn':'inn';
$innerArr[$coneNames]=$arrExpl[1];
}
}
$arrInsert[]=$innerArr;
}
 var_dump($arrInsert);

wanted to
3 => 
 array (size=3)
 'adress' => string 'City, street house.apartment' (length=142)
 'ogrn' => string '1234567890' (length=13)
 'inn' => string '0987654321' (length=10)


and get
3 => 
 array (size=1)
 'adress' => string 'City, street house.apartment' (length=142)
5 => 
 array (size=2)
 'ogrn' => string '1234567890' (length=13)
 'inn' => string '0987654321' (length=10)


why not tell me where I'm blunt and how ?
June 7th 19 at 14:50
1 answer
June 7th 19 at 14:52
You have the data adress and ogrn+inn lie in different divas.
First creates an array from the 1st diva, and ushitsa array to the result array. Then creates an array from the 2nd diva, and ushitsa in the result as a separate array.
Already understand unite using array_merge. - vergie.Jerde commented on June 7th 19 at 14:55

Find more questions by tags PHP