How to get all the pictures in the web page and store them in an array in php
This article describes the method of getting all the pictures in the web page in php and storing them in an array. Share it with everyone for your reference. The details are as follows:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
$images = array();
preg_match_all('/(img|src)=("|')[^"'>] /i', $data, $media);
unset($data);
$data=preg_replace('/(img|src)("|'|="|=')(.*)/i',"",$media[0]);
foreach($data as $url)
{
$info = pathinfo($url);
if (isset($info['extension']))
{
if (($info['extension'] == 'jpg') ||
($info['extension'] == 'jpeg') ||
($info['extension'] == 'gif') ||
($info['extension'] == 'png'))
array_push($images, $url);
}
}
|
1
2
3
4
5
6
7
8
9
10
11
12
1314
15
16
|
$images = array();
preg_match_all('/(img|src)=("|')[^"'>] /i', $data, $media);
unset($data);
$data=preg_replace('/(img|src)("|'|="|=')(.*)/i',"$3",$media[0]);
foreach($data as $url)
{
$info = pathinfo($url);
if (isset($info['extension']))
{
if (($info['extension'] == 'jpg') ||
($info['extension'] == 'jpeg') ||
($info['extension'] == 'gif') ||
($info['extension'] == 'png'))
array_push($images, $url);
}
}
|
I hope this article will be helpful to everyone’s PHP programming design.
http://www.bkjia.com/PHPjc/979667.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/979667.htmlTechArticleHow to get all the pictures in the web page and store them in an array in php. This article explains how to get all the pictures in the web page in php. method of entering an array. Share it with everyone for your reference. The details are as follows:...