从数据库表中获取图像的数据,在图像列中,我们有一个产品的 8 个不同尺寸的图像链接,每个图像链接都有其尺寸详细信息,例如:- 100x100、200x200、500x500 等。
所有图像都用逗号指定,例如:-
http://example.com/images/data/baby-care-100x100.jpg ,
http://example.com/images/data/baby-care-200x200.jpg ,
和更多.....
从此所有图片链接中,我需要找到 200x200 包含 img src 的链接
$productImage = array_key_exists('200x200', '$imageUrlStr')? $imageUrlStr['200x200']:'';
完整代码
$result = $mysqli->query("SELECT * FROM store where store= 'deals' AND bestOffer= '1' AND inStock= 'true' ");
while ($rows = $result->fetch_assoc()) {
$store = $rows["store"];
$productId = $rows["productId"];
$title = $rows["title"];
$description = $rows["description"];
$imageUrlStr = $rows["imageUrlStr"];
$productNewImage = array_key_exists('200x200', $imageUrlStr) ? $imageUrlStr['200x200'] : '';