Php 如何获取src="&引用;从html图像标记 $str=“此处的html代码和img标记”; PrggMatMatyALL('~)我建议您考虑使用,而不是用正则表达式解析IMG SRC标签。 $str = "html code here and img tag"; preg_match_all('~<img ([^>]+)>~i', $str, $matches); $images = array(); foreach ($matches[1] as $str) { preg_match_all('~([a-z]([a-z0-9]*)?)=("|\')(.*?)("|\')~is', $str, $pairs); } $html=file_get_html(“…html…”); //查找所有图像&echo src foreach($html->find('img')作为$element) echo$element->src.“”; > p>我建议您考虑使用,而不是用正则表达式解析IMG SRC标签。 $str = "html code here and img tag"; preg_match_all('~<img ([^>]+)>~i', $str, $matches); $images = array(); foreach ($matches[1] as $str) { preg_match_all('~([a-z]([a-z0-9]*)?)=("|\')(.*?)("|\')~is', $str, $pairs); } $html=file_get_html(“…html…”); //查找所有图像&echo src foreach($html->find('img')作为$element) echo$element->src.“”;
您可以在PHP中使用XML解析器,比如简单的HTML Dom,或者类似的正则表达式也可以Php 如何获取src="&引用;从html图像标记 $str=“此处的html代码和img标记”; PrggMatMatyALL('~)我建议您考虑使用,而不是用正则表达式解析IMG SRC标签。 $str = "html code here and img tag"; preg_match_all('~<img ([^>]+)>~i', $str, $matches); $images = array(); foreach ($matches[1] as $str) { preg_match_all('~([a-z]([a-z0-9]*)?)=("|\')(.*?)("|\')~is', $str, $pairs); } $html=file_get_html(“…html…”); //查找所有图像&echo src foreach($html->find('img')作为$element) echo$element->src.“”; > p>我建议您考虑使用,而不是用正则表达式解析IMG SRC标签。 $str = "html code here and img tag"; preg_match_all('~<img ([^>]+)>~i', $str, $matches); $images = array(); foreach ($matches[1] as $str) { preg_match_all('~([a-z]([a-z0-9]*)?)=("|\')(.*?)("|\')~is', $str, $pairs); } $html=file_get_html(“…html…”); //查找所有图像&echo src foreach($html->find('img')作为$element) echo$element->src.“”;,php,Php,您可以在PHP中使用XML解析器,比如简单的HTML Dom,或者类似的正则表达式也可以 $html = file_get_html('...html...'); // Find all images & echo src foreach($html->find('img') as $element) echo $element->src . '<br>'; 您可以在PHP中使用XML解析器,比如简单的HTMLDOM,或者类似的正则表达式也可以
$html = file_get_html('...html...');
// Find all images & echo src
foreach($html->find('img') as $element)
echo $element->src . '<br>';
您可以在PHP中使用XML解析器,比如简单的HTMLDOM,或者类似的正则表达式也可以
$html = file_get_html('...html...');
// Find all images & echo src
foreach($html->find('img') as $element)
echo $element->src . '<br>';
见:见: