i am using a script, to get the first image, inside a post.
Here is the script.
$first_img = '';
$my1content = $row['post_content'];
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $my1content, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){ //Defines a default image
$first_img = "/img/default.png";
}
This script echo the full image link, for example: http://mywebsite.com/images/thisistheimage.jpg
is possible to divide the image link , image name , and image extenction so i need to get 3 results
the link, example:http://mywebsite.com/images/ the image name, example: thisistheimage the image extenction, example: .jpg
Please let me know if its all clear, thanks for reading.