preg_replace all but digits and semicolon :
Posted: Mon Aug 24, 2009 4:09 am
Code: Select all
<?php
$string='255:125 bear';
$nvar = preg_replace('([\D])', '', $string);
echo $nvar; //returns 255125
$nvar = preg_replace('[\w]', '', $string);
echo $nvar; // returns :
?>