PHP get _php tutorial for pictures and div content instances in Web pages

Source: Internet
Author: User
The simple way to share the content of images and div in PHP is through regular expressions.

1. Get all the pictures in the webpage:

 
     $text = file_get_contents (' http://www.jbxue.com/'//  Preg_match_all $text $match  //print_r($match?>

2. Get the first picture in the Web page:

 
  PHP//$text=file_get_contents(' http://www.jbxue.com/'//  preg_match$text$match); // Print out Match Print_r ($match);? >

3. Gets the specific div chunk data for the specified page:

 
  PHP//$text=file_get_contents(' http://www.jbxue.com/'//  preg_match('/]*id= ' postcontent ' [^>]*> (. *?) 
 
   /si ',$text,$match); // print out match[0] Print ($match[0]);? >

4. The above 2 and 3 are combined:

 
     $text = file_get_contents (' http://www.jbxue.com/'//  Preg_match ('/]*id= ' Postcontent "[^>]*> (. *?) 
 
   /si ',$text,$match//preg_match$text  $match 2//print_r($match 2[0? >

http://www.bkjia.com/PHPjc/815972.html www.bkjia.com true http://www.bkjia.com/PHPjc/815972.html techarticle The simple way to share the content of images and div in PHP is through regular expressions. 1, get all the pictures on the page:? PHP//Get the content of the location address, and store ...

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