Loading array in preg_replace
<p>I'm trying to load my classes array in <code>preg_replace</code> but I am unable to get it to loop through the array. My 1st thought is, because I have a break in my code that is stopping the class from looping, however if I don't have a break in my loop the whole code will loop over and over instead of just the class string looping through.</p>

<p>This is what I have as my code, any suggestions?</p>

<pre><code>include('simple_html_dom.php'); 
$classes = array('red', 'blue', 'yellow', 'green', 'black');
$i=0;
$html = file_get_html('http://finance.yahoo.com/q/hp?s=^DJI&amp;a=05&amp;b=4&amp;c=2012&amp;d=06&amp;e=6&amp;f=2012&amp;g=d'); 
$symbol_gainers = '';
foreach ($html-&gt;find('.yfnc_datamodoutline1 td') as $element){
    $symbol_gainers .= $element-&gt;outertext;
    $sym_gainers = preg_replace('~(class="yfnc_tabledata1")~', 'class="'.$classes[$i++].'"', $symbol_gainers);
    print_r($sym_gainers);
    break;
}
</code></pre>

<p>EDIT: <a href="http://www.coderun.com/ide/?w=4DW972Uwjk6LvK_vX4ZqCQ" rel="nofollow">You can take a look at the code here with the functionality</a>.
Use Firebug to inspect the <code>td</code> of the HTML output, you will see it just repeats red red red over and over.</p>
