mamdouh asked this 4 years ago

PHP How to print associative array as a string ?

I have an associated array

$myarray = array(

                     "foo1" => "bar1",

                     "foo2" => "bar2" );

How can print this as a string?

 

                      


Best Answer by josh 1 year ago

foreach($myarray as $key => $value) {
    echo "Key=" . $key . ", Value=" . $value;
    echo "<br>";
}