I want to find and do some operations on this string:
<img src="images/video.png" border="0" alt="60" />
- Find every occurence in context
- Retrieve the alt attribute (in this case 60) and work with this number
- Replace the whole image
I've been playing around with regular expressions but it obviously doesn't work yet:
if (preg_match_all('<img src="images/video.png" border="0" alt="[^"]*">', $content, $regs)) {
for($i=0;$i<count($regs[0]);$i++){
echo $regs[0][$i] . "<br>";
$id = preg_replace('alt="[^"]*"', "$1", $regs[0][$i]);
echo "The id: " . $id . "<br>";
}
}