How to remove numbers from left string in php?
The function returns a substring from the left to the position with the first numeric character.
1. Code:
<?php function removeNumericFromLeftString($str){ $i = 0; while ($i <= strlen($str) - 1 && !is_numeric($str[$i])) { $i++; } return substr($str, 0, $i); } $str = "Soltuts.com1234 is providing PHP tutorials"; $str = removeNumericFromLeftString($str); echo($str); ?>
2. Example:
Input:
"Soltuts.com1234 is providing PHP tutorials"
Output:
Soltuts.com