Imploding an associative array in PHP
<p>Say I have an array:</p>

<pre><code>$array = Array(
  'foo' =&gt; 5,
  'bar' =&gt; 12,
  'baz' =&gt; 8
);
</code></pre>

<p>And I'd like to print a line of text in my view like this:</p>

<p>"The values are: foo (5), bar (12), baz (8)"</p>

<p>What I could do is this:</p>

<pre><code>$list = Array();
foreach ($array as $key =&gt; $value) {
  $list[] = "$key ($value)";
}
echo 'The values are: '.implode(', ',$list);
</code></pre>

<p>But I feel like there should be an easier way, without having to create the <code>$list</code> array as an extra step. I've been trying <code>array_map</code> and <code>array_walk</code>, but no success.</p>

<p>So my question is: what's the best and shortest way of doing this?</p>
