2012-07-25 139 views
0

我有代碼,我需要它來獲取具有以下內容的csv文件。從html創建csv

src of img.myImg; EAN的內容:Z88799010290

我試過,但沒有運氣如何合併兩個的foreach:

foreach($html->find('img.myImg') as $e) 
    echo $e->src . '<br>;'; 

foreach($html->find('div.EANN') as $ean) 
    echo $ean. ';<br>'; 
+0

請加上原有元素的一些樣品和所需結果的要素。 – Jay 2012-07-26 00:29:53

回答

0
<div id="wybr_45" alt="-8204" class="listProduct"><div id="d4b"> 

<div class="fl fotoimage"> 
    <div class="listLink1"> <a href="#" onclick="changeData('popshop','Mainframe','showModuleNew','DeepProductSelect',1234,1234);" > 
    <img src="http://example/script.php?a=87x112&amp;t=B2B.BSDTrade&amp;i=-441" class="myImg" alt="w"/> </a> 
    </div> 

</div> 


<div class="fl descriptionColumn"> 

<div class="lpTitle2 listName"><b> <a href="#">GATTA: MICHELLE LOVE pończochy samonośne wz.03</a></b></div> 
<div class="lpTitle2"><!-- <a href="#" >brak opisu </a> --></div> 
<span class="lpTitle2">Kod:</span><b>-8204</b> 
<div class="EANN">000245035190</div><div class="lpTitle2 producer">Producent: <a style="font-size: 12px; color: #555;" href="#">GATTA</a></div> 

</div> 

<div class="marketIndex"> 
<div class="priceColumn"> <span class="oldPrice1"> 
</span></div> 
<div class="OrderCpl"><span class="addtoOrderL" onclick="deepProductTable_showForProduct(-8204);" > 

<span onclick="deepProductTable_showForProduct(-8204);" class="addtobasket"/> </span></div> 
</div></div></div> 

結果:

http://example/script.php?a=87x112&amp;t=B2B.BSDTrade&amp;i=-723;000937090290