0

Without using a loop, is there a way (function) to convert, for example, the letter "c" to its numeric sequence in the alphabet (3)?

I'm trying to take a literal string - $var = "c" and apply a function to it that returns 3.

Are there any built-in PHP functions that do this? I can't find any online and would rather avoid writing the function if necessary.

Anyone know of such a conversion function?

CheeseConQueso
  • 5,831
  • 29
  • 93
  • 126

1 Answers1

0

Yup.

$alphabet_position = ord(strtoupper($character)) - ord('A');
Austin Mullins
  • 7,307
  • 2
  • 33
  • 48