当前位置:网站首页>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
?>
边栏推荐
猜你喜欢

Upload and modify the use of avatars

What are the ways to simulate and burn programs? (including common tools and usage)

Vulnérabilité à l'injection SQL (contournement)

Netease's open source distributed storage system curve officially became the CNCF sandbox project

Démarrer avec Apache shenyu

CSRF attack

视频会议一体机的技术实践和发展趋势

zabbix分布式系统监控

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

Getting started with Apache Shenyu
随机推荐
Checking whether the double value is an integer - Swift - checking if a double value is an integer - swift
金仓数据库 KingbaseES 插件force_view
龙书虎书鲸书啃不动?试试豆瓣评分9.5的猴书
Arrays. asList()
SQL注入漏洞(繞過篇)
Kingbasees plug-in ftutilx of Jincang database
Handler、Message、Looper、MessageQueue
Coscon'22 lecturer solicitation order
JVM 原理简介
Bayes
Upload and modify the use of avatars
SQL注入漏洞(类型篇)
How to start the phpstudy server
Apache ShenYu 入门
Kingbasees plug-in DBMS of Jincang database_ RANDOM
Kingbasees plug-in DBMS of Jincang database_ session
SystemVerilog(十三)-枚举数据类型
GC
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
16 enterprise architecture strategies