ted_chou12 Posted February 7, 2007 Share Posted February 7, 2007 preg_replace("^[0-9]", "test", $number); this doesnt replace all the numbers in the string, can anyone help me out? Thanks Ted Link to comment https://forums.phpfreaks.com/topic/37462-solved-preg-replace/ Share on other sites More sharing options...
Balmung-San Posted February 7, 2007 Share Posted February 7, 2007 Are you looking to replace them all, no matter where they are? If so: preg_replace("[0-9]","test",$number); should do it, however that replaces each digit with test. preg_replace("[0-9]*","test",$number); will replace them all, however each bit of numbers will be replaced by test, i.e. 333 becomes test, 33a33 becomes testatest, etc. Link to comment https://forums.phpfreaks.com/topic/37462-solved-preg-replace/#findComment-179120 Share on other sites More sharing options...
ted_chou12 Posted February 7, 2007 Author Share Posted February 7, 2007 oh, thanks, im looking for the first one! Ted Link to comment https://forums.phpfreaks.com/topic/37462-solved-preg-replace/#findComment-179122 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.