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

  • Home
  • SEARCH
  • 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 6170353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:01:19+00:00 2026-05-23T23:01:19+00:00

<?php $i == array(1, 2); $j == array(a, b); $m == count($j); $n ==

  • 0
<?php
  $i == array(1, 2); 
  $j == array(a, b); 
  $m == count($j); 
  $n == count($i); 
  for ( $i = 0; $i < $m; i++ ) 
  {
    for ( $j = 0; j < $n; j++) 
    { echo $i."x"$j; }
  }
?>

The error is referencing line 6: for ( $i = 0; $i < $m; i++ )

  • 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-23T23:01:21+00:00Added an answer on May 23, 2026 at 11:01 pm

    for ( $i = 0; $i < $m; $i++ )

    Note the dollar sign I added before the i++

    Same goes for your other for statement:

    for ( $j = 0; $j < $n; $j++ )

    Wierd error indeed, but it i is not a variable (although PHP might flag a E_NOTICE and convert it to 'i'. You want to reference your variable, so you must add a $ before.


    Most likely what you want is:

    <?php
      $iArray = array(1, 2); 
      $jArray = array('a', 'b'); 
      $n = count($iArray); 
      $m = count($jArray); 
      for ( $i = 0; $i < $n; $i++) {
        for ( $j = 0; $j < $m; $j++) { 
           echo $iArray[$i] . "x" . $jArray[$j]; 
        }
      }
    ?>
    

    The things I changed:

    • == is used for comparison, = is used for assignment
    • The second array I assumed you wanted the string literals 'a' and 'b', but you could have also wanted $a and $b if you declared those variables somewhere else
    • you assign $i to an array, but then in your for loop you overwrite it with $i = 0. You most likely want two variables
    • missing $s, like I mentioned above
    • $m was being used for the number of variables in $jArray, but you used it to iterate over $iArray

    So just a few pointers, brush up on you PHP and try to make sure your code works with every little change. Make 1 modification, then run it. It is very easy to get lost in syntax for PHP since it is such a dynamic scripting language

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<?php for ($i=1; $i<=(count($img_array))/4; $i++): ?> <input type=hidden id=img{$i}_name value=<?php echo ${'image_src'.$i};?> /> <?php
A PHP array can have arrays for its elements. And those arrays can have
Say I have an array of strings in a php array called $foo with
I have an array in PHP which holds a bunch of unix timestamps. As
How can I remove duplicate values from an array in PHP?
Is it possible to read the data in the php $_SESSION array in the
I'm working on a program that uses PHP's internal array pointers to iterate along
I'd like to be able to use php search an array (or better yet,
Is there an easy way to delete an element from an array using PHP,
PHP's explode function returns an array of strings split on some provided substring. 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.