preg_replace apply string function (like urlencode) in replacement

kooldude2233

New Member
i want to parse all links in html document string in php in such way: replace href='http://stackoverflow.com/questions/3556286/LINK' to href='http://stackoverflow.com/questions/3556286/MY_DOMAIN?URL=LINK', so because LINK will be url parameter it must be urlencoded. i'm trying to do so: \[code\]preg_replace('/href="http://stackoverflow.com/questions/3556286/(.+)"/', 'href="http://'.$host.'/?url='.urlencode('${1}').'"', $html);\[/code\]but '${1}' is just string literal, not founded in preg url, what need i do, to make this code working?
 
Back
Top