Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6731179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:29:50+00:00 2026-05-26T10:29:50+00:00

I am trying this loop, but i have a problem in $m[2][3] . None

  • 0

I am trying this loop, but i have a problem in $m[2][3]. None value is showed. So i have some problem with increments.

$nArr = array('A', 'B', 'C', 'D', 'E', 'F');

$lp = 4;

for ($i = 0; $i < $lp; $i++) {
    $m[$i][$i] = 1;
    for ($x = $i; $x < $lp; $x++) {
        $v = $i+$i;
        $m[$i][$x+1] = $nArr[$x+$v];
    }
}

this is my output :

1 + A + B + C + - 1 + D + E + - 1 +   + - 1 +

The output that i want:

1 + A + B + C + - 1 + D + E + - 1 + F + - 1 +

in detail:

echo $m[0][0]."+"; 1
echo $m[0][1]."+"; A
echo $m[0][2]."+"; B
echo $m[0][3]."+"; C
echo " - ";
echo $m[1][1]."+"; 1
echo $m[1][2]."+"; D
echo $m[1][3]."+"; E
echo "- ";
echo $m[2][2]."+";1
echo $m[2][3]."+"; //error, must be F
echo "- ";
echo $m[3][3]."+"; 1
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:29:51+00:00Added an answer on May 26, 2026 at 10:29 am

    Your problem is in your progression. In the second “for” your progression increases rapidly:

    $v = $i+$i;         
    $m[$i][$x+1] = $nArr[$x+$v]; 
    
    • In the first iteration starts with 0 + 0 + 0 ($ x + $ i + $ i) = 0 =
      “A”
    • In the second iteration begins with 1 + 1 + 1 ($ x + $ i + $ i) = 3 =
      “D”
    • and the third iteration begins with 2 + 2 + 2 ($ x + $ i + $ i) = 6 =
      null, your array has 6 elements so your max index is 5.

    You should change the progression in order to get the next progression of indexes: 0, 3, 5.

    Try this:

    $nArr = array('A', 'B', 'C', 'D', 'E', 'F');
    $lp = 4;                
    for ($i = 0; $i < $lp; $i++) {
         $m[$i][$i] = 1;            
        for ($x = $i; $x < $lp; $x++) {                
            $v = $i+ceil($i/2);
            $m[$i][$x+1] = $nArr[$x+$v];            
        }        
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to change this code to a for loop, but i have some
I've been trying this a few different ways, but I'm reaching the conclusion that
Well I have been trying this problem for over 10 hours and have no
I have this for loop in C: for (x=100;x>=3.0;x/=2){......} I am trying to write
I'm trying to load external SWFs in a for loop, and I have this
I'm trying to run this for loop; for (int col= 0; grid[0].length; col++) However
I am trying to do is to loop this HTML and get a nested
I am trying to loop from 100 to 0. How do I do this
I've been trying this a couple of different ways, but it's not working for
I am trying this in my Form Load Event cmdCancel.Attributes.Add(onClick, document.forms[0].reset();return false;) but it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.