...

View Full Version : Resolved str_repalce (remove numbers 123)



sitNsmile
04-02-2010, 04:54 PM
How do you replace numbers but not static, cause the numbers can change, so I need it to be able to replace any type of numbers?



<?
$test = "hello 123";
$resplace_test= str_replace("[0-9]", "", $test);
echo $test;
?>


Thanks

abduraooft
04-02-2010, 05:02 PM
<?php
$test = "hello 123";
$resplace_test= preg_replace("/[0-9]/", "", $test);
echo $resplace_test;
?>

PS: Using short open tag is a bad practice.

sitNsmile
04-02-2010, 05:34 PM
<?php
$test = "hello 123";
$resplace_test= preg_replace("/[0-9]/", "", $test);
echo $resplace_test;
?>

PS: Using short open tag is a bad practice.

I usually use the <?php but I was quickly just adding it for the forum.
-Thanks that did work.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum