当前位置:网站首页>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
?>
边栏推荐
- 金仓KFS数据集中场景(多对一)部署
- Leetcode 1249. 移除无效的括号(牛逼,终于做出来了)
- Free access to the global human settlements layer (ghsl) dataset from Gee
- 【上云精品】节能提效!加速纺织业“智造”转型
- 动态规划解决股票问题(上)
- Checking whether the double value is an integer - Swift - checking if a double value is an integer - swift
- 今天16:00 | 中科院计算所研究员孙晓明老师带大家走进量子的世界
- Network remote access using raspberry pie
- Jincang database kingbasees plug-in identity_ pwdexp
- scrapy+scrapyd+gerapy 爬虫调度框架
猜你喜欢

Jincang KFS data cascade scenario deployment

After reading this article, I will teach you to play with the penetration test target vulnhub - drivetingblues-7

Network remote access using raspberry pie

Technical practice and development trend of video conference all in one machine

JVM 原理简介

scrapy+scrapyd+gerapy 爬虫调度框架

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

Crawler scheduling framework of scratch+scratch+grammar

数据库系列:MySQL索引优化总结(综合版)

FPGA displays characters and pictures based on VGA
随机推荐
Course paper + code and executable EXE file of library information management system based on C language
Is it safe to open a securities account in changtou school by mobile phone?
金仓数据库 KingbaseES 插件force_view
GaussDB others内存比较高的场景
Use of three-level linkage plug-ins selected by provinces and cities
Spannable and editable, spannablestring and spannablestring
子类A继承父类B, A a = new A(); 则父类B构造函数、父类B静态代码块、父类B非静态代码块、子类A构造函数、子类A静态代码块、子类A非静态代码块 执行的先后顺序是?
June 24, 2022: golang multiple choice question, what does the following golang code output? A:1; B:3; C:4; D: Compilation failed. package main import ( “fmt“ ) func mai
如何实现移动端富文本编辑器功能
relu与sigmod的比较
try-catch-finally
Sign up to open the third session of the "flying oar hacker marathon". It's been a long time
手机办理长投学堂证券开户靠谱安全吗?
仿真与烧录程序有哪几种方式?(包含常用工具与使用方式)
Apache ShenYu 入門
每日3題(3)-檢查整數及其兩倍數是否存在
Free access to the global human settlements layer (ghsl) dataset from Gee
Kingbasees plug-in ftutilx of Jincang database
金仓数据库 KingbaseES 插件DBMS_RANDOM
2022年PMP项目管理考试敏捷知识点(2)