PHP get image path from text

Is it possible to get image path from some text using PHP ?
For example, we have a text with such code somewhere inside it This text is stored in DB (as article). How to get image path (in this example it is – from text? Of course, text and images varies from article to article
Use Regular Expressions in PHP , we can do it:

$text = '<img src="myimage.jpg"/>';
if((bool)preg_match('#<img[^>]+src=[\'"]([^\'"]+)[\'"]#', $text, $matches))
   echo 'Not found';

Leave a Reply