Remove Spaces
1 2 3 |
$string = str_replace(' ','',$string); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
<?php $string = "+447883012345"; // $string = "00447883031234"; // $string = "447883031234"; $string = str_replace(' ','',$string);//no spaces $string = str_replace('+','',$string); //no + sign echo $string." - START NUMBER<br>"; if (strlen($string) > 11) { if (substr($string, 0, 4) === '0044') { echo '<script>alert("0044 found and trimmed"); </script>'; $string = substr_replace($string, '0', 0, 4); } if (substr($string, 0, 2) === '00') { echo '<script>alert("00 found and trimmed"); </script>'; $string = substr_replace($string, '0', 0, 2); } if (substr($string, 0, 2) === '44') { echo '<script>alert("44 found and trimmed"); </script>'; $string = substr_replace($string, '0', 0, 2); } // $main = strlen($string); echo "END NUMBER = ".$string; } else { if (substr($string, 0, 2) === '44') { echo '<script>alert("11 numbers but 44 found and trimmed"); </script>'; $string = substr_replace($string, '0', 0, 2); } echo $string; } ?> |