bullet89 bullet89 - 1 month ago 5
PHP Question

how to get multidimensional array inner key of same values in php at once?

I had an array $data_rows

array(3) {
[0]=>
array(3) {
["ID"]=>
string(4) "C102"
["FName"]=>
string(4) "John"
["City"]=>
string(7) "Newyork"
}
[1]=>
array(3) {
["ID"]=>
string(4) "C104"
["FName"]=>
string(6) "Ramesh"
["City"]=>
string(6) "Mumbai"
}
[2]=>
array(3) {
["ID"]=>
string(4) "C105"
["FName"]=>
string(6) "Yuwang"
["City"]=>
string(7) "Beijing"
}
}


I had tried with array_keys($data_rows), it gives only

0,1,2


What can i put to get all the inner keys only once i.e.

ID,FName,City

Answer

Try this

print_r( array_keys( $data_rows[0] ) );
Comments