Does anyone know how can I cut only number or char from the string in php?
Example
$test = '12b';
any way that I can only cut the number from the variable: 12?
also and way that I can only cut out the char: b?
NOTE: the $test string flexible to changed.. means it could come with ‘123b’, ‘1a’…
Try this:
This will work for any combination of characters. All the digits will appear in $numeric, and all latin alphabet letters will appear in $alpha.
This will still work if the letters and numbers are reversed, or if other symbols appear in the string.