当前位置:网站首页>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
?>
边栏推荐
- Shen Lu, China Communications Institute: police open source Protocol - ofl v1.1 Introduction and Compliance Analysis
- Big endian and little endian
- Checking whether the double value is an integer - Swift - checking if a double value is an integer - swift
- [file containing vulnerability-03] six ways to exploit file containing vulnerabilities
- Complete steps for a complete Oracle uninstall
- Multiple environment variables
- FPGA基于VGA显示字符及图片
- Crawler scheduling framework of scratch+scratch+grammar
- Apache ShenYu 入门
- Apache ShenYu 入門
猜你喜欢

网易开源的分布式存储系统 Curve 正式成为 CNCF 沙箱项目

Complete steps for a complete Oracle uninstall

At 16:00 today, Mr. sunxiaoming, a researcher of the Institute of computing, Chinese Academy of Sciences, took you into the quantum world

基於Minifilter框架的雙緩沖透明加解密驅動 課程論文+項目源碼

Open source invites you to participate in the openssf Open Source Security Online Seminar

Task03 probability theory

网络远程访问的方式使用树莓派

开源社邀请您参加OpenSSF开源安全线上研讨会

Use of three-level linkage plug-ins selected by provinces and cities

CSRF attack
随机推荐
How to realize the rich text editor function of mobile terminal
Double tampon transparent cryptage et décryptage basé sur le cadre minifilter
Some assembly instructions specific to arm64
Explanation and use of kotlin syntax for Android
Five types of questions about network planning
Kingbasees plug-in DBMS of Jincang database_ OUTPUT
Query method and interrupt method to realize USART communication
金仓数据库 KingbaseES 插件dbms_session
A program reflecting the characteristics of C language program structure
金仓数据库 KingbaseES 插件DBMS_OUTPUT
从GEE中免费获取全球人类住区层 (GHSL) 数据集
[shangyun boutique] energy saving and efficiency improvement! Accelerating the transformation of "intelligent manufacturing" in the textile industry
Handling of NPM I installation problems
Jincang KFS data cascade scenario deployment
Writing wechat applet with uni app
try-catch-finally
scrapy+scrapyd+gerapy 爬虫调度框架
MySQL synchronous data configuration and shell script implementation
每日3题(3)-检查整数及其两倍数是否存在
Android之Kotlin语法详解与使用