你好,我有一个变量,它的文本如下:
<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<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>
和垃圾箱之间的文本呢。
preg_match_all("/<p>(.*?)<'/p>/is",$text,$matches,PREG_SET_ORDER);
foreach($maches as $match){
echo $match[1];
}
未测试!!
更新!