getting image src in php

后端 未结 4 1546
野趣味
野趣味 2021-01-16 07:17

how to get image source from an img tag using php function.

4条回答
  •  孤街浪徒
    2021-01-16 07:54

    Consider taking a look at this.

    I'm not sure if this is an accepted method of solving your problem, but check this code snippet out:

    // Create DOM from URL or file
    $html = file_get_html('http://www.google.com/');
    
    // Find all images 
    foreach($html->find('img') as $element) 
           echo $element->src . '
    '; // Find all links foreach($html->find('a') as $element) echo $element->href . '
    ';

提交回复
热议问题