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 8496111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:45:40+00:00 2026-06-10T23:45:40+00:00

Hi I have some simple code here that as far as I can tell

  • 0

Hi I have some simple code here that as far as I can tell should be working but it doesn’t and I am puzzled as to why

//VARIABLES
$rowcount=15;
$colcount=15;
$path= array( array());
$startrow=8;
$startcol=7;
$row=$startrow;
$col=$startcol;

for ($a=0;$a<$rowcount;$a++) {
    for ($b=0;$b<$colcount;$b++) {
        $path[$a][$b]=0;
    }
}

echo"In case one ";
echo"<BR>";
echo " Col= ".$col;
echo " Row= ".$row-1;
echo " Col= ".$col;
echo " Cell= ".$path[$row-1][$col];
echo " Cellx= ".$path[7][7];
if($path[$row-1][$col]=="o") {
    echo " F1 = ".$flagOne;
        $flagOne="1";
        echo " cell equals ==o==";
        echo " F1 = ".$flagOne;
} else {
    echo " cell not equal ==o==";
}
echo"<BR>";  

This is what I get as a output

In case one

Col= 7-1 Col= 7 Cell= 0 Cellx= 0 F1 = 0 cell equals ==o== F1 = 1

what puzzles me is the 7th spot “-1”
I would expect to see “Row= 7” not “-1” since $row=8

I have been programming in java and C and lately just barely touching PHP lately but I have been doing PHP for years, I think this should be working

what am i doing wrong

As another issue
looking at the if statement the value of the array/cell = 0 so I would also expect the evaluation to be false and echo this

cell not equal ==o==

but the condition is evaluating true why is this
my one thought is the way I am setting up the $path variable

I simply want it to be a simple two dimensional array $path[$a][$b] is it setup correctly when I output the array I see what I am expecting an two dimensional array.

Never had to do these much in the past

  • 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-06-10T23:45:42+00:00Added an answer on June 10, 2026 at 11:45 pm
    $rowcount=15;
    $colcount=15;
    $path= array( array());
    $startrow=8;
    $startcol=7;
    $row=$startrow;
    $col=$startcol;
    
    for ($a=0;$a<$rowcount;$a++) {
        for ($b=0;$b<$colcount;$b++) {
            $path[$a][$b]=0;
        }
    }
    
    echo"In case one ";
    echo"<BR>";
    echo " Col= ".$col;
    echo " Row= ".($row-1);
    echo " Col= ".$col;
    echo " Cell= ".$path[$row-1][$col];
    echo " Cellx= ".$path[7][7];
    if($path[$row-1][$col]==0) {
        echo " F1 = ".$flagOne;
            $flagOne="1";
            echo " cell equals ==0==";
            echo " F1 = ".$flagOne;
    } else {
        echo " cell not equal ==0==";
    }
    echo"<BR>";  
    

    At first, dont use double-quotes all over the script. There is a special meaning to double and single quotes in PHP, read the manual about this. Second – character “o” is not zero. You can clearly see, that You are trying to match zero against lower-case “o”. Also, integers does not need to be quoted in PHP just as in about every language out there. Check Your font settings to differ one from another. Third – If You are doing both evaluation and concatenation in PHP, You should surround evaluation statement with parentheses, although it is a bad practice. It is better to pre-calculate values and assign them to values before sending them to output or before concatenating them with another values as strings.

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

Sidebar

Related Questions

I have some simple javascript that as far as i can tell should work
I have some really simple code that's just not working: int[] manualPixels = new
I'have written a simple code, that gets accelerometer&orientation meter and display some graphics based
Here's some simple code that, for each argument specified, will add specific get/set methods
Here's our situation: We have some native code that scans user-defined directories at certain
I have some VERY simple code to return the title for a section header:
I have simple HTML code with some JavaScript. It looks like: <html> <head> <script
Question simple and quick: I have started to use Netbeans to write some code
Trying to get comfortable with jQuery and I have encountered some sample code that
So I have a few properties that I'm using in some sample code I'm

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.