PHP extracts the image addresses in the database content and outputs them cyclically.

Source: Internet
Author: User
PHP uses regular expressions to extract the output code of the image address loop in the database content. The code is as follows:
/*
1 (? S) indicates Pattern. DOTALL, that is, match the line feed, allowing the img to appear in multiple lines
2 .*? Indicates that non-greedy matches any character until the following conditions appear.
3? : Indicates that the match is not captured, that is, [\. gif | \. jpg] does not appear in the result.
*/
$ Pattern = "//";
$ Str ='

';
Preg_match_all ($ pattern, $ str, $ match );
Print_r ($ match );
/*
Array
(
[0] => Array
(
[0] =>
[1] =>
[2] =>
)
[1] => Array
(
[0] => upfiles/2009/07/1246430143_4.jpg
[1] => upfiles/2009/07/1246430143_3.jpg
[2] => upfiles/2009/07/1246430143_1.jpg
)
)
*/
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.