2009-12-12 6 views

답변

9
//split $s into paragraphs 
$a = explode("\r\n", $s); 

//extract the first $x paragraphs only 
$a = array_slice($a, 0, $x); 

//rejoin the paragraphs into a single string again 
$s = implode('\r\n', $a); 
+0

완벽하게 작동합니다. 감사합니다. – Dan

0

xml/html 환경에서 일반 텍스트가 아닌 경우 xml 또는 DOM 파서를 고려할 수 있습니다. 나는 PHP 녀석이 아니지만 php의 예제 돔 파서입니다. http://simplehtmldom.sourceforge.net/

간단한 API로 일반적으로 훨씬 더 유연하고 강력한 다음 파싱을 직접합니다.

관련 문제