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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:54:35+00:00 2026-06-05T07:54:35+00:00

This is the following JSON Structure over which I m trying to iterate {

  • 0

This is the following JSON Structure over which I m trying to iterate

{
   "AS":{
      "Query":"vi",
      "FullResults":1,
      "Results":[
         {
            "Type":"AS",
            "Suggests":[
               {
                  "Txt":"videos",
                  "Type":"AS",
                  "Sk":""
               },
               {
                  "Txt":"vipjatt",
                  "Type":"AS",
                  "Sk":"AS1"
               },
               {
                  "Txt":"vit",
                  "Type":"AS",
                  "Sk":"AS2"
               },
               {
                  "Txt":"vijaya bank",
                  "Type":"AS",
                  "Sk":"AS3"
               },
               {
                  "Txt":"videocon d2h",
                  "Type":"AS",
                  "Sk":"AS4"
               },
               {
                  "Txt":"visarev",
                  "Type":"AS",
                  "Sk":"AS5"
               },
               {
                  "Txt":"vijaya karnataka",
                  "Type":"AS",
                  "Sk":"AS6"
               },
               {
                  "Txt":"video songs",
                  "Type":"AS",
                  "Sk":"AS7"
               }
            ]
         }
      ]
   }
}

And this is the code I m using to iterate over it, and trying to access the “Txt” property

$data = $info->get($url);
$content = json_decode($data);
$i = 0;
foreach($content->AS->Results as $item) {
$each = $item->Suggests[$i]->Txt;
    $i++;
    echo $each;
}

But I only get the access of the first appearance of “Txt” property.
Whats wrong with my code ? Why isint it printing every appearance of the “Txt” property??

  • 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-05T07:54:38+00:00Added an answer on June 5, 2026 at 7:54 am

    You are iterating over the AS->Results items, of which there is exactly one. You want to iterate over the Suggests array directly:

    foreach ($content->AS->Results[0]->Suggests as $item) {
        echo $item->Txt;
    }
    

    I don’t know if there could be more than one item in the Results array. Perhaps you need to first iterate over them to pick out the right Suggests item to iterate over.

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

Sidebar

Related Questions

So, I have the following structure in JSON, which I understand to be an
I am sending over the following JSON structure: { header: Staff Name, result:[ {firstname:Leo,id:1,lastname:name},
I write an application which creates a JSON File following the below structure: {
I've got the following JSON provided from a server. With this, I want to
For some reasons this part where I fetch JSON data from following url will
I have a xPage with following content: <xe:restService id=restService preventDojoStore=false> <xe:this.service> <xe:viewJsonService viewName=vwChartData contentType=text/json>
I am currently data into a local db as following: window.localStorage.setItem('QQIDVAL' + ID, JSON.stringify(this));
I have this following IEnumerable LINQ query: var query = from p in Enumerable.Range(2,
I have an html form that has the following structure: <input type=text name=title />
I have MySQL database, where I store the following BLOB (which contains JSON object)

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.