i want to replace every space in a link with %20.
<a href="Replace the spaces here">Some text</a>
i want to get This:
<a href="Replace%20the%20spaces%20here">Some text</a>
not this:
<a%20href="Replace%20the%20spaces%20here">Some%20text</a>
How to do this? preg_replace? Solution (because I cant post an answer):
$search= '(href="(.*?)")s';
$replace= '';
$newstring= preg_replace_callback($search,create_function('$treffer','urlencode($treffer[0]);'),$string);