How to extract image names with php or regex -


i have following data in mysql.

<p><img src="../../../../assets/images/frontpage/image1.png"  alt="" width="790" height="356" /></p> 

now want image2.png php or regex. extension can gif or jpg. , length of image name can length.

how can it.

thanks help.

this match path in img tag , capture file in first interior capturing group.

<?php if (preg_match('%<img\s.*?src=".*?/?([^/]+?(\.gif|\.png|\.jpg))"%s', $subject, $regs)) {     $image = $regs[1]; } else {     $image = ""; } ?> 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -