Categories
PHP

A Handy alphabet class :)

Another funny class with no serious use. This is a class I wrote to determine the numerical positions of letters in the English alphabet.

How to use ?

As you can see, using the getNum() method, you can feed a letter and get the serial number or numerical position of that letter. Again in the same way, use the getChar() method to input a number and get the character/letter in that position.

I use it very often while breaking alphabet related codes.

Source Codes:

One reply on “A Handy alphabet class :)”

// Do you really need this line?
$this->alpha[] = ‘z’; // manually add z to the array

// You could modify this line
for($i=’a’;$ialpha[]= $i; }
// to
for($i=’a’;$ialpha[]= $i; }

Would that work?

Comments are closed.