我试图让我的数组在 foreach 循环中循环,但它一遍又一遍地循环同一个。我究竟做错了什么?
$classes = array('red', 'blue', 'yellow', 'green', 'black', 'purple', 'grey');
foreach($classes as $class){
foreach ($html->find('.yfnc_datamodoutline1 .yfnc_tabledata1') as $element){
$symbols = $element->outertext;
echo '<div class="'.$class.'">'.$symbols.'</div>';
}
它输出这个
<div class="red">Jul 6, 2012</div>
<div class="red">12,889.40</div>
<div class="red">12,889.40</div>
<div class="red">12,702.99</div>
<div class="red">12,772.47</div>
<div class="red">967,600</div>
<div class="red">12,772.47</div>
我试图让它输出这个
<div class="red">Jul 6, 2012</div>
<div class="blue">12,889.40</div>
<div class="yellow">12,889.40</div>
<div class="green">12,702.99</div>
<div class="black">12,772.47</div>
<div class="purple">967,600</div>
<div class="grey">12,772.47</div>