remove the first characters of each string in a foreach
<p>How can I remove the first characters <code>characters_to_eliminate</code> of each string in a <code>foreach</code> loop?
EDIT: <code>characters_to_eliminate</code> are 3 random characters, they are not always the same.
In line 6 I try:</p>

<pre><code>$val = substr($val, 3);
</code></pre>

<p>but only removes the first 3 characters of the first value in the array.</p>

<pre><code>function multiexplode ($delimiters,$string) {
    $ary = explode($delimiters[0],$string);
    array_shift($delimiters);
    if($delimiters != NULL) {
        foreach($ary as $key =&gt; $val) {
            $ary[$key] = multiexplode($delimiters, $val);
        }
    }
    return  $ary;
}

// Example of use
$string = "characters_to_eliminate abc, characters_to_eliminate def: characters_to_eliminate ghi, characters_to_eliminate jkl";
$delimiters = Array(",",":");

$res = multiexplode($delimiters,$string);
echo '&lt;pre&gt;';
print_r($res);
echo '&lt;/pre&gt;';
</code></pre>
