How to print keys and values in an array
P粉204079743
2023-08-06 14:18:22
<p>I'm trying to format my array like this: Name is John, Age is 30. Here is my sample array and code: </p>
<pre class="brush:php;toolbar:false;">$user = array(
'name' => 'John',
'age' => 35
);
echo key($user)." is ".($user[key($user)]).","; // prints "name is John,"</pre>
<p>If there are no more results to print, the comma (,) will disappear. <br /><br />I'm not very good at logic, but can you help me? This will be a big help! Thank you in advance. </p><p><br /></p>
or