Iterate through array and get key and value [duplicate] Iterate through array and get key and value [duplicate] php php

Iterate through array and get key and value [duplicate]


I´d go for a recursive function: If a value is an array, call it again and otherwise display the key / value pair.

Something like (not tested):

function display_array($your_array){    foreach ($your_array as $key => $value)    {        if is_array($value)        {            display_array($value);        }        else        {             echo "Key: $key; Value: $value<br />\n";        }    }}display_array($some_array);