【发布时间】:2018-09-24 08:15:42
【问题描述】:
我想更改已解析 html 中特定链接的 URL 结尾。在以前的场合我使用过这段代码
$html = file_get_html('URL');
// search for .htm change to .php
foreach ($html->find("td a") as $a) {
$a->href = substr_replace($a->href, 'php', -3);
但它会改变所有的链接。我现在必须区分特定的 URL。我只想更改那些不在其链接中包含“框”的链接。
Example:
thisismyboxlink123.htm --> no change of ending please
thisismyotherlink123.htm --> thisismyotherlink123.php
【问题讨论】: