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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:45:23+00:00 2026-05-20T12:45:23+00:00

I have the following json data: { data: [ { name: The Frugalicious Chef,

  • 0

I have the following json data:

{
   "data": [
      {
         "name": "The Frugalicious Chef",
         "category": "Chef",
         "id": "186397894735983",
         "created_time": "2011-03-07T16:10:35+0000"
      },
      {
         "name": "Siuslaw Broadband",
         "category": "Telecommunication",
         "id": "190373850988171",
         "created_time": "2011-03-06T20:21:42+0000"
      },
      {
         "name": "Paul",
         "category": "Movie",
         "id": "129989595478",
         "created_time": "2011-03-04T19:55:18+0000"
      },
      {
         "name": "Mark Zuckerberg",
         "category": "Public figure",
         "id": "68310606562",
         "created_time": "2011-02-16T09:50:35+0000"
      },

The idea here is that I want to take this data and use parts of it. I want to create a list of the “category’s” that are in the data. The problem is that there is and will be multiple items with the same category. So my list will have duplicates that I do not want. The following is how I am getting the data and converting it for use:

$jsonurl = "https://xxxxxxxxxx.com/".$fd_ID. "/info?access_token=".$session['access_token'];
$likesjson = file_get_contents($jsonurl,0,null,null);
$likesArray=json_decode($likesjson);

I then use a foreach to access the data.

foreach($friendLikesArray->data as $l)
{
etc......
}

So I guess muy question is I want to take the $likesArray and pull out all the unique Data->Category->names. Also will want to do sorting, and other things but I will get to that when the time comes.

Thanks for the help in advance.
Neil

  • 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-20T12:45:24+00:00Added an answer on May 20, 2026 at 12:45 pm

    The data structure you would want to use is a set, that only allows unique entries.

    A simple implementation using PHP arrays is to use the keys.

    e.g.

    $categories = array();
    
    foreach($friendLikesArray->data as $l)
    {
        $categories[$l->category] = true;
    }
    
    $categories = array_keys($categories);
    

    This way if the category has already been added, then you are not adding anything new to the array.

    If the keys are not important to you then you can use the line:

    $categories[$l->category] = $l->category
    

    But this means your array won’t have 0,1,2…n for keys.

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

Sidebar

Related Questions

I have the following javascript: $.ajax({ type: "POST", dataType: "json", url: "/Home/Submit", data: {
I have the following ajax call to webservice to pass json data and get
say I have the following json object; {'fname':'john', 'lname':'Locke'} and the following text boxes
I basically have the following flow: XML -> JSON -> Spring MVC -> jsp
I have the following JSON date returned from a MVC page e.g. DateProcessed:\/Date(1258125238090)\/ and
I have a php query the returns the following JSON format from a table.
I have the following javascript which I need to make dynamic. data.addRows(2); data.setValue(0, 0,
I have the following code: var json = MyObject .Select(p => new { id
I have the following json as seen below. I'm trying to read the values
How do I parse the following json returned from Facebook? I have tried by

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.