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; } ?> 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). 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 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
Archived
This topic is now archived and is closed to further replies.