I have this string: 13.23E. What I need is to cut the letter E (or any last letter) to obtain two vars, one with the number, on with the letter.
Example:
$var = "12345E";
print_r(removeLastLetter($var));
// OUTPUT
array(
[0] => "12345",
[1] => "E"
)
Any help?
Thanks.
function removeLastLetter($string)
{
$part1 = substr($string, 0, -1); // get chars upto last
$part2 = substr($string, -1); // get last char
return array($part1, $part2);
}
Output:
Array
(
[0] => 12345
[1] => E
)
Demo!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With