teomanersan Posted June 20, 2006 Share Posted June 20, 2006 hi guys..i`d like to ask how to accomplish using urlencode() function inside a preg_replace function and inverse of preg_replace..$string = preg_replace('#\[star](.*?)\[/star\]#is','<a href="blabla.php?ara=\\1">*</a>',$string);works fine.. but i have to add a urlencode() to the link... so i tried some stuff like below$string = preg_replace('#\[star](.*?)\[/star\]#is','<a href="blabla.php?ara='.urlencode(\\1).'" >*</a>',$string);which is not working.. it`s encoding \\1 and not the $string.. how can i make it encode the string ??the second question is how can i take the inverse of this preg_replace().. simply when i get$string = <a href="blabla.php?ara=\\1">*</a>' , i want it to write [star]$string[/star]thanks for your time..good coding.. Quote Link to comment https://forums.phpfreaks.com/topic/12495-2-preg_replace-question/ Share on other sites More sharing options...
wildteen88 Posted June 21, 2006 Share Posted June 21, 2006 You'll want to use the e modify like so:$string = preg_replace('#\[star](.*?)\[/star\]#ise','<a href="blabla.php?ara='.urlencode(\\1).'" >*</a>',$string); Quote Link to comment https://forums.phpfreaks.com/topic/12495-2-preg_replace-question/#findComment-47976 Share on other sites More sharing options...
teomanersan Posted June 21, 2006 Author Share Posted June 21, 2006 [!--quoteo(post=386337:date=Jun 21 2006, 02:06 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Jun 21 2006, 02:06 PM) [snapback]386337[/snapback][/div][div class=\'quotemain\'][!--quotec--]You'll want to use the e modify like so:$string = preg_replace('#\[star](.*?)\[/star\]#ise','<a href="blabla.php?ara='.urlencode(\\1).'" >*</a>',$string);[/quote]thanks a lot for the reply but this code is not working..i googled this problem and couldn`t find much and the ones i found didnt work :(please, i need help about this problem..thx for ur timegood coding.. Quote Link to comment https://forums.phpfreaks.com/topic/12495-2-preg_replace-question/#findComment-48017 Share on other sites More sharing options...
teomanersan Posted June 21, 2006 Author Share Posted June 21, 2006 ok i figured out it and did something like this and it works..[code]$string = preg_replace("#\[star](.*?)\[/star\]#ise", "'<a href=\"/blabla.php?ara='.urlencode('\\1').'\" >*</a>'",$string);[/code]i need a reference manual something to sort out this syntax problems, any link / help is highly appericiated..thx for ur time..good coding.. Quote Link to comment https://forums.phpfreaks.com/topic/12495-2-preg_replace-question/#findComment-48132 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.