Is there a built in function that can calculate the distance between 2 chars? for example:
if i want to calculate the distance between a
and c
the result should be 1
because there is one letter in between a
and c
.
I did a function to achieve that, but i need to know if there is a built in solution or a simpler one
function str_distance($a, $b){
$cant = 0;
while(true){
if (++$a == $b)
return $cant;
$cant++;
}
}
But this wont work when calculating z
to b
or any calculations that gets to the end of the alphabet.
Any suggestions?