<?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