Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert integers to characters in PHP

Tags:

php

How to create a function for converting integers to characters in PHP like this:

'A' => 0,
'B' => 1,
'C' => 2,
'D' => 3,
'E' => 4,
'F' => 5,
'G' => 6,
'H' => 7,
'I' => 8,
'J' => 9

If number is 100, then it should generate BAA.

The A, B, C... are just an example. I am trying to encrypt the numbers with a code.

I need this to work with some word like

0 => zero
1 => one

etc

But when I give number 10, it should output onezero.

like image 454
Safi Baig Avatar asked Oct 20 '25 04:10

Safi Baig


1 Answers

Simple try like this

    $letter = chr($i+65);
    echo $letter;

gives 'A'

like image 52
Gautam3164 Avatar answered Oct 22 '25 19:10

Gautam3164



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!