当前位置:网站首页>How PHP extracts image addresses from strings
How PHP extracts image addresses from strings
2022-06-25 11:19:00 【Liu Yang's dream making program development station】
Sometimes we have a need to extract the picture address in the product details and make it into an array , So that mall users can download pictures with one click ,PHP Extract the picture address in the string , In fact, it uses regular expressions to match image addresses , Let's look directly at the code
<?php
$str='<p><img border="0" src="upfiles/2009/07/1246430143_1.jpg" alt=""/></p>';// Product details page code
$pattern="/<[img|IMG].*?src=[\'|\"](.*?(?:[\.gif|\.jpg]))[\'|\"].*?[\/]?>/";
preg_match_all($pattern,$str,$match);
print_r($match);//$match[0] For the extracted picture , Can be used directly ,$match[1] Is the extracted picture address , Need to write img Labeled src in
?>
边栏推荐
- 过拟合原因及解决
- [shangyun boutique] energy saving and efficiency improvement! Accelerating the transformation of "intelligent manufacturing" in the textile industry
- Spannable and editable, spannablestring and spannablestring
- Dynamic programming to solve stock problems (Part 1)
- SQL注入漏洞(类型篇)
- Double tampon transparent cryptage et décryptage basé sur le cadre minifilter
- ZABBIX distributed system monitoring
- Leetcode 1249. Remove invalid brackets (awesome, finally made)
- Comparator(用于Arrays.sort)
- 16 种企业架构策略
猜你喜欢
C disk uses 100% cleaning method
報名開啟|飛槳黑客馬拉松第三期如約而至,久等啦
Netease's open source distributed storage system curve officially became the CNCF sandbox project
JVM 原理简介
金仓KFS数据集中场景(多对一)部署
Writing wechat applet with uni app
Démarrer avec Apache shenyu
[file inclusion vulnerability-04] classic interview question: how to getshell when a website is known to have only local file inclusion vulnerability?
SystemVerilog(十三)-枚举数据类型
Use of three-level linkage plug-ins selected by provinces and cities
随机推荐
Task03 probability theory
视频会议一体机的技术实践和发展趋势
手机办理长投学堂证券开户靠谱安全吗?
SystemVerilog(十三)-枚举数据类型
Jincang database kingbasees plug-in force_ view
每日3题(3)-检查整数及其两倍数是否存在
Apache ShenYu 入门
try-catch-finally
Cdn+cos ultra detailed steps for drawing bed construction
Technical practice and development trend of video conference all in one machine
Network remote access using raspberry pie
Spannable and editable, spannablestring and spannablestring
MySQL synchronous data configuration and shell script implementation
Arrays.asList()
[shangyun boutique] energy saving and efficiency improvement! Accelerating the transformation of "intelligent manufacturing" in the textile industry
Daily 3 questions (2) - find out the lucky numbers in the array
GaussDB others内存比较高的场景
Gaussdb others scenarios with high memory
Causes and solutions of over fitting
今天16:00 | 中科院计算所研究员孙晓明老师带大家走进量子的世界