Posted By

melvitax on 03/11/08


Tagged

img


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

Wiederkehr
SpinZ
NARKOZ
wirenaught


Grab SRC from IMG tag


 / Published in: PHP
 

  1. $str = '<h2> this is a test</h2><img src="pathrourl.jpg" alt="test" />';
  2. $find = '/<img.*src="(.*?)"/';
  3. $match = preg_match($find, $str, $img );
  4. if ( $match )
  5. echo $img[1];

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: melvitax on March 11, 2008

You need to login to post a comment.