Skip to content
Advertisement

How to get values of a multidimensional array with a string

I have an multidimensional array

$array[0]["searched0"] = "text0";
$array[1]["searched1"] = "text1";
...

Now I want to get “text1” but I only know it is $array[1] but not the name “searched1”. Is there a possibility to get the searched parameter?

Advertisement

Answer

With reset() you get the first element.

echo reset($array[1]);  //text1
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement