I have digit string and convert into letters.
$arr = str_split('12345');
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
)
Now I want to Convert 1 = A, 2 = B, ...
I have digit string and convert into letters.
$arr = str_split('12345');
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
)
Now I want to Convert 1 = A, 2 = B, ...
Easiest solution I can think of right now:
$arr = str_split('12345');
$arr2 = str_split('abcdefghijklmnopqrstuvwxyz');
foreach($arr as &$digit)
$digit = $arr2[$digit-1];
note that $digit
is passed to the loop by reference using a &
symbol. That means that when you manipulate $digit
, the respective array entry in $arr
will be changed as well.