mamdouh asked this 7 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 4 years ago

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