Looping Through Post Content w/stripos
-
Hello,
I have a plugin that gets the first image from the content of a post. Here’s the code:
// Image extraction $image = ''; $x = stripos($content, '<img'); if ($x !== false) { $x = stripos($content, 'src="', $x); if ($x !== false) { $x += 5; $y = strpos($content, '"', $x); $image = substr($content, $x, $y-$x); } }
The “$x = stripos($content, ‘<img’);” finds the first instance of <img and returns the result. I would like to modify this to get the 2nd image if the first image found is “header.gif”.
Any suggestions on how to modify the code to accomplish this?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Looping Through Post Content w/stripos’ is closed to new replies.