I need to take img src from record after a query:
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
  $rows[] = array(
     'id' => $row['ID_CONTENT'],
     'titolo' => $row['TITOLO'],
     'articolo' => $row['DESCRIZIONE'],
     'giorno' => $row['GIORNO'],
     'foto' => "get img src from this: $row['DESCRIZIONE']",
     'fonte' => $row['FONTE']
);}
Is it possible?
I try with preg_match_all('/<img[^>]+>/i',$row['DESCRIZIONE'],$res[0]) but get only 1 as result!
OK I SOLVE SO:
Create a function:
function srcImg($num) {
            preg_match('@src="([^"]+)"@',$num,$match);
            $src = array_pop($match);
            return $src;
         }
and then:
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
  $rows[] = array(
     'id' => $row['ID_CONTENT'],
     'titolo' => $row['TITOLO'],
     'articolo' => $row['DESCRIZIONE'],
     'giorno' => $row['GIORNO'],
     'foto' => srcImg($row['DESCRIZIONE']),
     'fonte' => $row['FONTE']
);}
echo json_encode($rows);
 
    