Hell i am having a matrix like , well it's not as a matrix matrix[100][100] , but... I have something like vector['city']['X']=number So ... if i have a list of vectors like this vector['newyork']['aaa'] vector['newyork']['aab'] ... vector['chicago']['hui'] ... vector['bucharest']['ddfg'] How i can parse them all ?!
I known that if it was about a simple array then i could do $arr = array(1, 2, 3, 4); foreach ($arr as &$value) { $value = $value * 2; }
If you want to access each element in the "New York" subarray (e.g get each $vector['NewYork'][X] value) you would do this: foreach ($vector['NewYork'] as $key => $value) echo $key, ' => ', $value, "\n"; PHP: If you need to find out the names of all the cities (e.g., $vector['NewYork'], $vector['chicago'], etc.) use $cities = array_keys($vector); echo "Here are all your cities:\n"; foreach ($cities as $city) echo "$city\n"; PHP: