riceje7 Posted November 17, 2009 Share Posted November 17, 2009 i'm trying to strip out all punctuation from a string but it doesn't seem to work right. the function is just outputing the same text that is input. here is my code any help would be great. thanks <?php function parsetext($text){ rtrim($text); preg_replace("/[^a-zA-Z0-9 ]/",'',$text); strtolower($text); echo $text; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/181891-solved-problems-with-preg_replace-function/ Share on other sites More sharing options...
Daniel0 Posted November 17, 2009 Share Posted November 17, 2009 preg_replace() returns the result of the replace. It doesn't have any side-effects (i.e. it doesn't actually modify $text). Quote Link to comment https://forums.phpfreaks.com/topic/181891-solved-problems-with-preg_replace-function/#findComment-959293 Share on other sites More sharing options...
riceje7 Posted November 17, 2009 Author Share Posted November 17, 2009 ooooh. okay thanks i guess i just needed to add '$text = ' to the beginning of the preg_replace function thanks a ton Quote Link to comment https://forums.phpfreaks.com/topic/181891-solved-problems-with-preg_replace-function/#findComment-959301 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.