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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:20:57+00:00 2026-05-21T22:20:57+00:00

I am looking for a way to count the number of items (in PHP)

  • 0

I am looking for a way to count the number of items (in PHP) returned in these JSON strings I am getting when searching a database.

Forgive me because I’m utterly crap at all of this.

I was told because there is no count returned in the JSON version, like there is in the XML one from this database, I would have to use a loop to count the number of results?

I’ve had a look around but nothing seems to fit what I want to do…

The following is an example of the strings I get:

Array ( 
  [0] => stdClass Object ( 
    [score] => 12
    [popularity] => 3
    [name] => Samantha Dark
    [id] => 151019
    [biography] => [url] => http://www.themoviedb.org/person/151019
    [profile] => Array ( )
    [version] => 16
    [last_modified_at] => 2011-04-11 17:17:33
  )

  [1] => stdClass Object (
    [score] => 11
    [popularity] => 3
    [name] => Johnny Dark
    [id] => 158737
    [biography] => [url] => http://www.themoviedb.org/person/158737
    [profile] => Array ( )
    [version] => 14
    [last_modified_at] => 2011-04-11 17:18:38
  )
)

and if applicable, here’s the php I use to request & decipher it

$name = $_GET['search'];
$persons_result = $tmdb->searchPerson($name);
$persons = json_decode($persons_result);

foreach ($persons as $person) {
  echo '<a href="tmdb_person.php?id='.$person->id.'">'.$person->name.'</a></br>';
}
  • 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-21T22:20:58+00:00Added an answer on May 21, 2026 at 10:20 pm

    Use the count function on $persons to get the number of items.

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

Sidebar

Related Questions

I'm looking for the most elegant way to count the same number values in
I'm looking for a easy way to count the unknown number of characters in
I'm looking for a way to count and number/rename files in a directory with
I'm looking for a way to count the number of times a value is
I am looking for a way to count the number of lines in a
I'm looking for a way to count the amount of minutes each player (or
I'm dealing with a database where items are tagged a certain number of times.
I was looking for the best way to find the number of running processes
I am looking for a way to quickly remove items from a C# List<T>
I'm looking for a way to count the distinct periods without gaps students have

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.