lehula Posted July 14, 2007 Share Posted July 14, 2007 I'm retrieving all images in a section of my source code. I want it to skip all the images that have the id="blocker". I've tried using strpos to search for the id in the image src. I then try to skip the image with that id by using the 'continue' expression, but it's not working. Can someone help me out? Thanks. //retrieve all images within the above string preg_match_all('#<img\s[^>]*src\s*=\s*[\'"]?([^\'"\s>]+)[\'"]?[\s>]#i', $matches[0], $images); foreach($images[1] as $image) { $ider = 'id="blocker"'; $pos = strpos($image, $ider); if ($pos === true) { continue;} else { echo "document.getElementById('randompic".$h."').src=\"".$image."\";"; echo "document.getElementById(\"picaddress".$h."\").value = \"".$image."\";"; echo "document.getElementById('randompic".$h."').style.visibility = \"visible\";"; echo "document.getElementById(\"randomcheck".$h."\").checked = \"true\";"; echo "document.getElementById('randompreview".$h."').src=\"".$image."\";"; $h++;} } Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted July 14, 2007 Share Posted July 14, 2007 try <?php preg_match_all('#<img(?!>)*?>#i', $matches[0], $images); foreach($images[1] as $image) { $ider = 'id="blocker"'; $pos = strpos($image, $ider); if ($pos !== false) { echo "document.getElementById('randompic".$h."').src=\"".$image."\";"; echo "document.getElementById(\"picaddress".$h."\").value = \"".$image."\";"; echo "document.getElementById('randompic".$h."').style.visibility = \"visible\";"; echo "document.getElementById(\"randomcheck".$h."\").checked = \"true\";"; echo "document.getElementById('randompreview".$h."').src=\"".$image."\";"; $h++;} } ?> Quote Link to comment Share on other sites More sharing options...
lehula Posted July 15, 2007 Author Share Posted July 15, 2007 thanks for the help, but it's not retrieving any images with that. Ill keep trying. Quote Link to comment Share on other sites More sharing options...
lehula Posted July 15, 2007 Author Share Posted July 15, 2007 I can't get it to work, any help from anyone would be great Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.