Guest Posted June 28, 2008 Share Posted June 28, 2008 I want to encode a part of what was found with preg replace but when i try this it actually encodes $2 not the value of it. Is this possible to do? Please help Link to comment https://forums.phpfreaks.com/topic/112372-solved-preg_replace-urlencode2/ Share on other sites More sharing options...
sasa Posted June 29, 2008 Share Posted June 29, 2008 yes Link to comment https://forums.phpfreaks.com/topic/112372-solved-preg_replace-urlencode2/#findComment-577097 Share on other sites More sharing options...
Guest Posted June 29, 2008 Share Posted June 29, 2008 Can you please tell me how this is what I have and its not working $result = preg_replace('#href="([^"*])"#is', urlencode($1), $result) Link to comment https://forums.phpfreaks.com/topic/112372-solved-preg_replace-urlencode2/#findComment-577099 Share on other sites More sharing options...
sasa Posted June 29, 2008 Share Posted June 29, 2008 try <?php function my_urlencode($a){ return urlencode($a[1]); } echo $result = preg_replace_callback('#href="([^"]*)"#is', 'my_urlencode', $result); ?> Link to comment https://forums.phpfreaks.com/topic/112372-solved-preg_replace-urlencode2/#findComment-577154 Share on other sites More sharing options...
Guest Posted June 29, 2008 Share Posted June 29, 2008 Thank you that did it completely. Link to comment https://forums.phpfreaks.com/topic/112372-solved-preg_replace-urlencode2/#findComment-577432 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.