close

How to increment a letter N times per iteration and store in an array?

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error How to increment a letter N times per iteration and store in an array? in php. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How to increment a letter N times per iteration and store in an array Error Occurs?

Today I get the following error How to increment a letter N times per iteration and store in an array? in php.

How To Solve increment a letter N times per iteration and store in an array Error ?

  1. How To Solve increment a letter N times per iteration and store in an array Error ?

    To Solve increment a letter N times per iteration and store in an array Error You need to get the ASCII value for that character which will solve your problem.

  2. How to increment a letter N times per iteration and store in an array?

    To Solve increment a letter N times per iteration and store in an array Error You need to get the ASCII value for that character which will solve your problem.

Solution 1

Here is your solution for the problem,

$letter = array();
for ($i = 'A'; $i !== 'ZZ'; $i++){
        if(ord($i) % 2 != 0)
           $letter[] .= $i;
}
print_r($letter);

You need to get the ASCII value for that character which will solve your problem.

Here is ord doc and working code.

For your requirement, you can do like this,

for ($i = 'A'; $i !== 'ZZ'; ord($i)+$x){
  $letter[] .= $i;
}
print_r($letter);

Here set $x as per your requirement.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read

Leave a Comment