There is a field (description) in the database

<img src="images1.png" alt=""> Картинка 1 - Автомобиль Ваз <img src="images2.png" alt=""> Картинка 2 - Автомобиль УАЗ <img src="images2.png" alt=""> Картинка 3 - Автомобиль Lada 

How to get out of here only img That is, what would be the output I got

 <img src="images1.png" alt=""> <img src="images2.png" alt=""> <img src="images3.png" alt=""> 
  • I think we need to completely pull the field out of the base, after which, in php, extract img from it with a simple regular schedule - Mike
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

2 answers 2

MySQL? There are regular sessions so as not to oversimplify:

 SELECT * FROM `table` WHERE description REGEXP '(<img.+?>)' 

And according to the result, in PHP we process:

 preg_match_all('/(<img.+?>)/is', $result, $matches); 

The $ matches array will contain an array of all img tags.

They can be put on one line like this:

 $glued = implode('', $matches); 
    1. Select description from table // pull out from the base
    2. preg_match('#<(.*')>#si', $result, $arr) // cut the necessary $arr[0][0] // deduce that, in <>