note 31743 added to function.preg-match-all
| From: | amien at perwanalnumberten dot com | Date: | Fri, 02 May 2003 08:16:49 +0000 |
| Subject: | note 31743 added to function.preg-match-all | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-47374@lists.php.net to get a copy of this message | ||
here's how to retrieve image names from a html generator .. the purpose is to upload image
files without an annoying browse buttons ... usually used in WYSIWYG editor ..
function get_images_upload($string)
{
preg_match_all( '/\<img src=.*?\>/',$string,$tags );
for ($count = 0; $count < sizeof($tags[0]) ; $count++)
{
preg_match_all( '/\'.*?\'/', $tags[0][$count], $img );
for ($x = 0; $x < sizeof($img[0]) ; $x++)
{
$final_name[$x]=str_replace ("'"," ", $img[0][$x]);
}
}
}
$string="<img src='aa.jpg'>psakldpasdsad<img
src='bb.jpg'>dfdsfsd<img src='cc.jpg'><b>dasd<img
src='ddfdfds.jpg'>s</b><a href='php.net'>";
get_images_upload($string)
output should be :
aa.jpg
bb.jpg
etc..etc..
--
http://www.php.net/manual/en/function.preg-match-all.php
http://master.php.net/manage/user-notes.php?action=edit+31743
http://master.php.net/manage/user-notes.php?action=delete+31743
http://master.php.net/manage/user-notes.php?action=reject+31743