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 :
?>Moderator: General Moderators
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 :
?>Code: Select all
preg_replace('/[^0-9\:]/', null, $str);