[PHP] Grabbing image information from an html string
Let say I have an html string that looks like this: bTitleb img src=graphics/image1.jpgfoo bar bar fooimg src=graphics/image2.jpgSome more text. I would like to pull the image filenames from the html and end up with something like this $images=array(image1.jpg, image2.jpg) How can I do this? thanks, Luis R. Lebron Project Manager Sigmatech, Inc
RE: [PHP] Grabbing image information from an html string
if (preg_match('/(href|HREF)=?(\S+\.(jpg|png))?/',$line, $matches)){ $filename[] = $matches[2]; } -Original Message- From: Luis Lebron [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 26, 2003 7:07 AM To: Php-General (E-mail) Subject: [PHP] Grabbing image information from an html string Let say I have an html string that looks like this: bTitleb img src=graphics/image1.jpgfoo bar bar fooimg src=graphics/image2.jpgSome more text. I would like to pull the image filenames from the html and end up with something like this $images=array(image1.jpg, image2.jpg) How can I do this? thanks, Luis R. Lebron Project Manager Sigmatech, Inc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Grabbing image information from an html string
You need to use preg_match_all() and a more greedy expression that is not case sensitive.. preg_match_all('/src=(\S*)/i', $html, $matches); $image_array = $matches[1]; HTH, Kevin - Original Message - From: Dan Rossi [EMAIL PROTECTED] To: Luis Lebron [EMAIL PROTECTED]; Php-General (E-mail) [EMAIL PROTECTED] Sent: Tuesday, March 25, 2003 12:39 PM Subject: RE: [PHP] Grabbing image information from an html string if (preg_match('/(href|HREF)=?(\S+\.(jpg|png))?/',$line, $matches)){ $filename[] = $matches[2]; } -Original Message- From: Luis Lebron [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 26, 2003 7:07 AM To: Php-General (E-mail) Subject: [PHP] Grabbing image information from an html string Let say I have an html string that looks like this: bTitleb img src=graphics/image1.jpgfoo bar bar fooimg src=graphics/image2.jpgSome more text. I would like to pull the image filenames from the html and end up with something like this $images=array(image1.jpg, image2.jpg) How can I do this? thanks, Luis R. Lebron Project Manager Sigmatech, Inc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php