<?php
require_once("simple_html_dom.php");
$str = '<div class="content"><span>text1</span><span>text2</span><span>text3</span><span>text4</span><span>text5</span><span>text6</span><span>text7</span><span>text8</span><span>text9</span><span>text10</span><span>text11</span><span>text12</span><span>text13</span><span>text14</span><span>text15</span><span>text16</span></div>';
$dom = html_entity_decode($str);
$html = str_get_html($dom);
foreach($html->find('span') as $e)
echo $e . '<br>';
?>
在此代碼中,它可以在一行中回顯每個跨度。但是,我如何編寫它,以便將3個結果合併成一個foreach?如何將3個結果合併爲1 foreach(PHP html DOM)
我需要一個像結果:
text1 text2 text3 <br />
text4 text5 text6 <br />
text7 text8 text9 <br />
text10 text11 text12 <br />
text13 text14 text15 <br />
text16
我身上有一種與這一段代碼幻覺記憶的什麼,我寫了http://www.codinghorror.com/blog/2007/02/why-cant-programmers-program.html – Trufa 2011-01-31 19:11:57