2012-03-20 98 views
-1
删除

你好我有了下面的文本变量:PHP字符的字符串

<p>Not sure exactly which property you want to extract, but I assume it's the 'question_answers_url'.</p> 

<pre><code>$answersArray = Array(); 
for($i=0;$i&lt;count($jsonArray['questions']);$i++){ 
    //assuming it is the 'question_answers_url' property that you want 
    array_push($answersArray,$jsonArray['questions'][$i]['question_answers_url']); 
} 
</code></pre> 

<p>Ought to do it.</p> 

我怎样才能得到这是唯一<p>TEXT_I_WANT</p>和垃圾一切之间的文本。

+0

我在您的文字的任何地方都看不到'

TEXT_I_WANT

'。 [你有什么尝试?](http://mattgemmell.com/2008/12/08/what-have-you-tried/) – Graham 2012-03-20 11:14:01

+0

你是什么意思?我想p之间的文字 – 2012-03-20 11:15:17

+0

我试图分裂文字为字符,然后试图弄清楚是否 2012-03-20 11:17:47

回答

2
preg_match_all("/<p>(.*?)<\/p>/is",$text,$matches,PREG_SET_ORDER); 
foreach($maches as $match){ 
    echo $match[1]; 
} 

未经测试!

更新!

+0

警告:preg_match_all():.....中的未知修饰符'p'和警告:为...中的foreach()提供了无效参数.... – 2012-03-20 11:13:56