C
C
CrewCut2015-12-11 23:09:11
PHP
CrewCut, 2015-12-11 23:09:11

How to create such a nested array?

At the input there is xml data that I want to process and output to an array. Example of initial data:

<Cities City_ID="1196910018" City_owner_ID="0" CityName="52127 городок" RegionName="Московская обл." Region_ID="40" Region_Owner_ID="0" Country_ID="209" Country_Owner_ID="0"/>
<Cities City_ID="1940" City_owner_ID="0" CityName="Якшур-Бодья" RegionName="Удмуртская респ." Region_ID="84" Region_Owner_ID="0" Country_ID="209" Country_Owner_ID="0"/>
<Cities City_ID="1196906999" City_owner_ID="0" CityName="4-й Участок" RegionName="Московская обл." Region_ID="40" Region_Owner_ID="0" Country_ID="209" Country_Owner_ID="0"/>

At the output, you need an array:
[0] => Moscow region ('52127 town', '4th Plot');
[1] => Udmurt Republic ('Yakshur-Bodya');
Those. array where key = RegionName and value is an array of CityName for that RegionName

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question