Applying a function all values in an array
<p>$jobs is an array retrieved from a DB query. <code>print_r($jobs)</code> shows:</p>

<pre><code>Array
(
    [ID] =&gt; 131
    [Title] =&gt; -bla-
    [Baseline] =&gt; lorem ipsum ...
    [Description] =&gt; &lt;ul&gt;&lt;li&gt;list 1&lt;/li&gt;&lt;li&gt;list 2&lt;/li&gt;&lt;/ul&gt;
    [EventID] =&gt; 1008
)
Array
(
    [ID] =&gt; 132
    [Title] =&gt; -bla 2-
    [Baseline] =&gt; lorem ipsum lorem ipsum...
    [Description] =&gt; &lt;ul&gt;&lt;li&gt;list 1&lt;/li&gt;&lt;li&gt;list 2&lt;/li&gt;&lt;/ul&gt;
    [EventID] =&gt; 1009
)
</code></pre>

<p>etc ...</p>

<p>Id like to run utf8_encode() on all values of these arrays. I'm not sure if I should use array_map, array_walk_recursive ? The output should not alter the names of the array keys so that I don't need to change anything in my template, so</p>

<pre><code>&lt;h1&gt;&lt;?=$j['title']?&gt;&lt;/h1&gt;
</code></pre>

<p>should still work, albeit utf8 encoded.</p>

<p>EDIT: I'm trying the following, no luck</p>

<pre><code>function fix_chars($key, $value)
{
    return utf8_encode($value);
}

array_walk_recursive($jobs, 'fix_chars');
</code></pre>
