2015-05-22 39 views
1

我试图让文本介于标记之间。继承人我到目前为止:preg_match a <title="">标记和显示

$new4 = '><strong> Rating:</strong><span> <span class="rl s5" title="A 5 Star(s)">A'; 

preg_match('/title="(.*?)">">/', $new4, $output); 
echo '<pre>'; 
print_r($output); 
echo '</pre>'; 

所有我得到的是一个空白数组,不知道我哪里去错了。

+2

你不必'<标题=''在$ new4'。你也可以把'preg_match'放在一个条件中,然后你就会知道你的正则表达式何时工作,什么时候没有。 'if(preg_match('/ title =“(。*?)”>“> /',$ new4,$ output)){print_r($ output);} else {echo'no matches :(';}' – chris85

+0

好吧,在你的更新中你没有在'$ new4'中有''>>>'',你在下面的答案应该适用于所提供的例子。如果你的问题还有更多的问题,请发布要求。 – chris85

回答

1

试试这个:

preg_match('/title="(.*?)"/', $new4, $output);