<?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에서 결합되도록 어떻게 작성해야합니까? 당신의 foreach 루프에서 나머지 연산자 %
를 사용3 개의 결과를 결합하는 방법 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
확인을 위해 쓴에이 코드 조각 데자뷰의 종류가 있었다 덕분에 나는 일종의 데자뷰를 읽을 것이다. –