1

みなさん、こんにちは。読んでくれてありがとう。私はこのようなリンクを持っています:

<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.it/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=monte+rosa&amp;aq=&amp;sll=45.454082,9.213138&amp;sspn=0.009016,0.01929&amp;t=h&amp;gl=it&amp;ie=UTF8&amp;hq=&amp;hnear=Monte+Rosa,+Province+of+Varese,+Lombardy&amp;ll=45.690627,8.824349&amp;spn=0.008978,0.01929&amp;z=14&amp;iwloc=A&amp;output=embed"></iframe><br /><small><a href="https://maps.google.it/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=monte+rosa&amp;aq=&amp;sll=45.454082,9.213138&amp;sspn=0.009016,0.01929&amp;t=h&amp;gl=it&amp;ie=UTF8&amp;hq=&amp;hnear=Monte+Rosa,+Province+of+Varese,+Lombardy&amp;ll=45.690627,8.824349&amp;spn=0.008978,0.01929&amp;z=14&amp;iwloc=A" style="color:#0000FF;text-align:left">View Larger Map</a></small>

これだけ抜き出したい

https://maps.google.it/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=monte+rosa&amp;aq=&amp;sll=45.454082,9.213138&amp;sspn=0.009016,0.01929&amp;t=h&amp;gl=it&amp;ie=UTF8&amp;hq=&amp;hnear=Monte+Rosa,+Province+of+Varese,+Lombardy&amp;ll=45.690627,8.824349&amp;spn=0.008978,0.01929&amp;z=14&amp;iwloc=A&amp;output=embed

つまり、 src=" からリンクの最後までのすべてを抽出したい ". 正規表現を使用してみましたが、正しい構文がわかりません。いくつかの助けをいただければ幸いです。

4

1 に答える 1

3
$html = '<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.it/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=monte+rosa&amp;aq=&amp;sll=45.454082,9.213138&amp;sspn=0.009016,0.01929&amp;t=h&amp;gl=it&amp;ie=UTF8&amp;hq=&amp;hnear=Monte+Rosa,+Province+of+Varese,+Lombardy&amp;ll=45.690627,8.824349&amp;spn=0.008978,0.01929&amp;z=14&amp;iwloc=A&amp;output=embed"></iframe><br /><small><a href="https://maps.google.it/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=monte+rosa&amp;aq=&amp;sll=45.454082,9.213138&amp;sspn=0.009016,0.01929&amp;t=h&amp;gl=it&amp;ie=UTF8&amp;hq=&amp;hnear=Monte+Rosa,+Province+of+Varese,+Lombardy&amp;ll=45.690627,8.824349&amp;spn=0.008978,0.01929&amp;z=14&amp;iwloc=A" style="color:#0000FF;text-align:left">View Larger Map</a></small>';
preg_match('~iframe.*src="([^"]*)"~', $html, $result);
var_dump($result[1]);
于 2013-03-11T16:16:37.587 に答える