PHP is extracting all of the IMG attribute values, PHP extracts the img attribute value _php Tutorial

Source: Internet
Author: User

PHP is extracting all of the IMG attribute values, PHP extracts the img attribute value


$ext= ' gif|jpg|jpeg|bmp|png ';//list image suffixes to achieve multi-extension matching by http://www.k686.com Green software$str= ''; $list=Array();//The result map is stored here$c 1=Preg_match_all('/php is extracting all the attribute values of IMG/',$str,$m 1);//Remove all img Tag Text First for($i= 0;$i<$c 1;$i++) {//take attributes on all img tags    $c 2=Preg_match_all('/(\w+) \s*=\s* (?:(?:( ["\']) (.*?) (? =\2)) | ([^\/\s]*)) /',$m 1[0] [$i],$m 2);//match all of the attributes     for($j= 0;$j<$c 2;$j++) {//structural reorganization of matched results        $list[$i][$m 2[1] [$j]] = !Empty($m 2[4] [$j]) ?$m 2[4] [$j] :$m 2[3] [$j]; }  }  Print_r($list);//View result Variables

http://www.bkjia.com/PHPjc/1059462.html www.bkjia.com true http://www.bkjia.com/PHPjc/1059462.html techarticle PHP is extracting all of the IMG attribute values, PHP extracts the img attribute value $ext = ' gif|jpg|jpeg|bmp|png ';//list the image suffix to achieve multiple extension matching by http://www.k686.com Green software $st ...

  • 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.