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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:09:21+00:00 2026-05-26T07:09:21+00:00

I am having the worst time trying to get this to work. In the

  • 0

I am having the worst time trying to get this to work. In the following code, I am gathering data from a database query and trying to build a muti-dimensional array object that will keep totals and tally up some information in a specific way. The problem is that instead of getting a value that is incrementing as it should, the value seems to be suffering from the last value it was assigned problem. Here is the code:

        $REVIEWS      = array();
        $USER_REVIEWS = array();
        $USER_IMGREVS = array();


        pseudo-code: loop here which iterates over the DB results creating
        $date - which is into this function as its called for each day of month
        $p1user - which is one of the users (there are 3) 'levels' of users
        $hr - is the hour which is built from the transaction's timestamp

        $hr     = date('H', $row['P1TIMESTAMP']);
        $p1user = $row['P1USER'];

        $REVIEWS[$date] += 1;
        $USER_REVIEWS[$date][$p1user][$hr] += 1;
        $USER_IMGREVS[$date][$p1user][$hr] += $row['F5'];

        print "PASS1<br/>\n";
        print "Value of Total Reviews: [".$REVIEWS[$date]."]<br/>\n";
        print "Value of User Reviews: [".$USER_REVIEWS[$date][$p1user][$hr]."]<br/>\n";
        print "Value of Reviewed Images: [".$USER_IMGREVS[$date][$p1user][$hr]."]<br/>\n";
        print "<br/><br/>\n";

So – the ‘total reviews’ increments by one, as it should, for each time i print this. SO far so good. The next two arrays will only print the last values they were assigned, and will not be added together like they should. Why not? I have attempted to do this another way by literally creating the arrays one by one and assigning them in whole to the array containing them – but that also does not seem to work. Any insights?

  • 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-26T07:09:22+00:00Added an answer on May 26, 2026 at 7:09 am

    i don’t know how you initilize your array, maybe this will help:

    // replace this 2 lines:
    $USER_REVIEWS[$date][$p1user][$hr] += 1;
    $USER_IMGREVS[$date][$p1user][$hr] += $row['F5'];
    
    // with this code:
    if (!isset($USER_REVIEWS[$date]))
        $USER_REVIEWS[$date] = array();
    if (!isset($USER_REVIEWS[$date][$p1user]))
        $USER_REVIEWS[$date][$p1user] = array();
    if (!isset($USER_REVIEWS[$date][$p1user][$hr]))
        $USER_REVIEWS[$date][$p1user][$hr] = 0;
    $USER_REVIEWS[$date][$p1user][$hr] += 1;
    
    if (!isset($USER_IMGREVS[$date]))
        $USER_IMGREVS[$date] = array();
    if (!isset($USER_IMGREVS[$date][$p1user]))
        $USER_IMGREVS[$date][$p1user] = array();
    if (!isset($USER_IMGREVS[$date][$p1user][$hr]))
        $USER_IMGREVS[$date][$p1user][$hr] = 0;
    $USER_IMGREVS[$date][$p1user][$hr] += $row['F5'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having the worlds worst time trying to understand how to save anything
An algorithm having worst-case running time of O(N^2) took 30secs to run for input
So, I'm having a little trouble trying to make a card reader work properly
I'm having the worst time getting key value observing working in with a UITextView's
So I keep getting this error when trying to compile C++ code using CodeBlocks.
I am having the worst luck with this. We bought a template to update
I am trying to spread out data that is received in bursts. This means
I'm trying to keep from cutting and pasting code so I made a wrapper
I'm having a really hard time debugging this. When I try to print out
Having the following class: public class SomeClass { private readonly int[] _someThings; public SomeClass()

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.