将href的内容插入URL参数中


Insert contents of href into a URL parameter

这是我的问题,例如,我的页面上有一个链接,它看起来像:

<a href="12/345/67.php">Stuff here</a> - on page 1

简单的东西。

问题是,当单击该链接时,我需要它将href="部分的内容写入第二页的url参数。因此:

page2.php?url=12/345/67.php

这里的另一个问题是,我正在使用简单的html-dom web scraper来制作这个页面(第1页),所以我得到了这样的链接:

$html = file_get_html('http://www.somesite.com/somepage.html');
foreach($html->find('a') as $e)
    $e->style= 'color:#000; padding-left:5px; text-align:left;';

有什么想法吗?提前感谢!

试试这样的东西:

$href = urlencode($e->href);
$e->href = "page2.php?url=$href";