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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:37:51+00:00 2026-06-15T16:37:51+00:00

Edit Thanks for all the input on this, I did find error in my

  • 0

Edit

Thanks for all the input on this, I did find error in my question so modifying now. Sorry for that.

I am trying to figure out how to return the last object in the JSON string I have rendered. The two functions I am working with:

public function revision($return = false)
    {
        $id = $this->input->post('galleryID');
        $data = array('revision_count' => $this->revision->count_revision($id) );

        if($return){
            return json_encode($data);
        }
        else {
            echo json_encode($data);
        }
    }

public function last_revision()
        {
            $allRevisions = json_decode($this->revision(),true);
            return end($allRevisions);
        }

The issue is that end() returns error stating that 1st parameter should be array.

Thanks for any help on this.

  • 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-15T16:37:52+00:00Added an answer on June 15, 2026 at 4:37 pm

    It is important to note here that json_decode returns an instance of stdClass by default. Try using json_decode($jsonstring, true) to return the JSON as a PHP associative array.

    However, You haven’t included what the $this->revision() method does. Could you possibly show that portion of the code, since that is the function you are getting a return value from?

    Edit:

    Alright, after we saw the right function in your code, here are a couple of things I would like to say:

    • You have added a $return parameter to your revision method, but you aren’t using it when you need to. You should change $this->revision() to $this->revision(true) in your last_revision method.
    • If you’re going to return data from the revision() method, there’s not much of a point in json_encodeing it, just to json_decode the result. Just pass back the raw data array.
    • Once you have changed both of these things, this should work:

      $allRevisions = $this->revision(true); return end($allRevisions['revision_count']);

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

Sidebar

Related Questions

EDIT Thanks to all for your input. I guess my question was just a
UPDATE: I recently learned from this question that in the entire discussion below, I
This program produces the output I expect when given an input file of text
So I realize this is a possible duplicate question, as there a number of
I'm trying to gather a Unicode list of all the 'o' like shapes in
Well, I'm trying to log user login history, so for this I need to
I have an input form, nested within a div, defined like this: <div class=login-input>
I've got a bit of a usability issue that I'd value some input on.
Hey, This is just a simple exercise from class that I decided to have
In Delphi 2006, I am showing a modal form. User input in that form

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.