retrieve only images without a certain id.
Posted: Sat Jul 14, 2007 4:35 pm
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.
Code: Select all
//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++;}
}