This article mainly introduces php's method of getting all the images on the web page and saving them to an array. it involves php regular expression matching and array operations, which is of great practical value, for more information about how to use php to retrieve all images on a webpage and store them in an array, see the following example. Share it with you for your reference. The details are as follows:
$ 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 help you with php programming.