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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:16:47+00:00 2026-05-22T01:16:47+00:00

I am trying to write a bunch of nested if statements that are somewhat

  • 0

I am trying to write a bunch of nested if statements that are somewhat as follows:

if (strcmp($data['reports'][$i][$j],$data['reports'][$i][$j-1])){

but as you all know, you have to write a separate if statement if it is 0, because 0-1 doesn’t exist.

    if ($j == 0){
 //First report, to prevent OBOB
        echo "<br/><a href = ".$filename.">".$data['reports'][$i][$j]."</a>";

#-> You would have to write two more statements here to test for province...
}

    if ($j >= 1){
 //All subsequent reports
      if (strcmp($data['reports'][$i][$j],$data['reports'][$i][$j-1])){
        echo "<br/><a href = ".$filename.">".$data['reports'][$i][$j]."</a>";
#-> You would have to write two more statements here to test for province...
    }

Now, imagine if you have to test other dependent values for sequential identicality?

It goes from 4 to 8 to 16 separate statements to just test for 4 of these…

So, I just had the idea to stuff crap into $j = -1.

        $data['reports'][$i][-1]='aaaaaaaaaa'; 
// This would depend on the type of data you are
// comparing I suppose it could be zeros.
        $data['provinces'][$i][-1]='aaaaaaaaa';

Is there a better solution?

  • 1 1 Answer
  • 1 View
  • 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-22T01:16:47+00:00Added an answer on May 22, 2026 at 1:16 am

    Why don’t you just start your loop with 1 instead of 0? That is, instead of this:

    for ($j = 0; $j < count($data['reports'][$i]); $j++ )
    

    do this:

    for ($j = 1; $j < count($data['reports'][$i]); $j++ )
    

    It’s pointless to compare the first array element to the previous one anyway, so just skip it.

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

Sidebar

Related Questions

I'm trying to write a Lisp macro that writes a bunch of macros, but
I am trying write a function that generates simulated data but if the simulated
I have a bunch of collection-like COM interfaces that I'm trying to write an
I've been trying to write an extend function so I can have bunch of
I'm trying to write a bash script that would modify all occurrences of a
I have a data structure in mind that involves nested enums, such that I
I'm trying to write code that talks to Google Spreadsheets. We do a bunch
I'm trying to write a bunch of unit tests for all of my different
I m trying write code that after reset set up rrpmax as 3000. It
Trying to write app for service technicians that will display open service calls within

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.