0

How to convert multidimensional associative array to indexed array?

I have a multidimensional array like this $arr=array( "Student1"=>array("name"=>"jon","age"=>"33","marks"="44"), "Student2"=> array("name"=>"jonas","age"=>"23","marks"="64"), "Student3"=> array("name"=>"kim","age"=>"35","marks"="74") ); I need output as:- Array(name=>jon, Age=>33, Marks=>44 , name=>jonas, Age=>23, Marks=>64, name=>kim, Age=>35, Marks=>75

1st Dec 2022, 2:41 AM
parajal12
parajal12 - avatar
2 odpowiedzi
+ 1
PHP does not distingish between indexed and associative array. And you cannot use the same key to store another value without overwriting the previous value. You can make a new array without using "Student#" as keys, but integer indice will be used in their places. Is one of these outputs acceptable? https://code.sololearn.com/wKu3x779U07l/?ref=app
1st Dec 2022, 3:28 AM
Lochard
Lochard - avatar