php - regexp to match all images without link -


this question has answer here:

i use regex match images. how can rewrite match images without </a> in end ?

preg_match_all ("/\<img ([^>]*)\/*\>/i", $text, $dst);   

soap box

i don't recommend using regex parse html string.

however

however might want try using dom first loop through images , store them in array.

foreach ($dom->getelementsbytagname('img') $img) {     $array[$img->getattribue('src')]=1; } 

then loop through links , try find image inside remove array.

foreach ($dom->getelementsbytagname('a') $a) {     //loop catch multiple imgs in links     foreach ($a->getelementsbytagname('img') $img) {          unset($array[$img->getattribue('src')]);     } } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -