How to select rows that start with “<img”

前端 未结 1 1459
無奈伤痛
無奈伤痛 2021-01-29 06:05

I have two columns, Entry and text_image, in a table. When looping to see all the rows in an array, I can get the results, but I want it to add

相关标签:
1条回答
  • 2021-01-29 07:06
    $images = (substr($row['text_image'], 0, 3) == 'img') ? "/images" : "";
    echo $images . $row['text_image'];
    

    This will check if the first 3 letters of $row['text_image'] are img then set $images to /images else it will leave it empty. This will update each time within the loop.

    0 讨论(0)
提交回复
热议问题