I know this may seem rather simple, but I am stumped on how to go about accomplishing this task.
I need to remove all HTML IMG tags from an array key/value, then take those removed HTML IMG tags and push them back onto the same array, with it’s own separate array key this time.
Sample:
$array = array(
'content' => '<img src="http://www.domain.com/images/img.png" width="100" height="100" alt="" />here is some content that might also be in this string.'
);
$array = array(
'content' => 'here is some content that might also be in this string.',
'image' => '<img src="http://www.domain.com/images/img.png" width="100" height="100" alt="" />'
);
The HTML IMG tag and the rest of the text within the string will always be different. The content will never be exactly the same, so I don’t really know how to go about doing this. I was thinking about explode() or str_replace().
You need a regular expression. Something like:
This will tell you the number of matches, with the information on the matches (including the matched string and the offset of the match string, which you would use to remove content from the original string)