How can I list the values & make variable with the values of this json? (In PHP)


So I have tried that:

$json = json_decode($response, true); echo $json['link'];

but I didn’t get anything as output.

I have this json object:

{"results":[{"title":"Cat | global-selector | Caterpillar","link":"","description":"Cookies are small files that are placed on your computer and retrieved by the website in order to make this website work more efficiently and to better ...‎English · ‎Français · ‎Turkish","additional_links":[{"text":"Cat | global-selector | Caterpillar","href":""},{"text":"English","href":""},{"text":"Français","href":""},{"text":"Turkish","href":""}],"cite":{}},{"title":"Cat - Wikipedia","link":"","description":"The cat (Felis catus) is a domestic species of small carnivorous mammal. It is the only domesticated species in the family Felidae and is often referred to ...Species: F. catusKingdom: AnimaliaGenus: FelisClass: Mammalia‎Evolution · ‎Characteristics · ‎Senses · ‎Behavior","additional_links":[{"text":"Cat - Wikipedia › wiki › Cat","href":""},{"text":"Animalia","href":""},{"text":"Felis","href":""},{"text":"Mammalia","href":""},{"text":"Evolution","href":""},{"text":"Characteristics","href":""},{"text":"Senses","href":""},{"text":"Behavior","href":""}],"cite":{"domain":" › wiki › Cat","span":" › wiki › Cat"}},{"title":"Caterpillar | Caterpillar","link":"","description":"Cat® product offerings include articulated trucks, backhoe loaders, dozers, engines, excavators, generators, motor graders, skid steer loaders and wheel loaders ...","additional_links":[{"text":"Caterpillar | Caterpillar","href":""}],"cite":{}},{"title":"cat | Breeds & Facts | Britannica","link":"","description":"Dec 13, 2021 — Cat, domesticated member of the family Felidae, order Carnivora, and the smallest member of that family. Like all felids, cats are ...","additional_links":[{"text":"cat | Breeds & Facts | Britannica › animal › cat","href":""}],"cite":{"domain":" › animal › cat","span":" › animal › cat"}},{"title":"Caterpillar Inc. (CAT) Stock Price, News, Quote & History","link":"","description":"Find the latest Caterpillar Inc. (CAT) stock quote, history, news and other vital information to help you with your stock trading and investing.","additional_links":[{"text":"Caterpillar Inc. (CAT) Stock Price, News, Quote & History › quote › CAT","href":""}],"cite":{"domain":" › quote › CAT","span":" › quote › CAT"}},{"title":"Cat | National Geographic","link":"","description":"Domestic Cat · Relationship with Humans. Felis catus has had a very long relationship with humans. · Hunting Abilities. Like their wild relatives, domestic cats ...","additional_links":[{"text":"Cat | National Geographic › domestic-cat","href":""}],"cite":{"domain":" › domestic-cat","span":" › domestic-cat"}},{"title":"Cat Breeds | Types of Cats | Purina","link":"","description":"American Bobtail Cat BreedAmerican Curl Cat BreedAmerican Shorthair CatAmerican Wirehair Cat BreedBalinese-Javanese Cat BreedBengal CatBirman Cat BreedBombay CatBritish Shorthair Cat BreedBurmese CatChartreux Cat Breed","additional_links":[{"text":"Cat Breeds | Types of Cats | Purina › Cats","href":""}],"cite":{"domain":" › Cats","span":" › Cats"}},{"title":"Cat Adoption Team | Sherwood Cat Rescue | Cat Adoption ...","link":"","description":"Cat Adoption Team is the largest nonprofit, adoption guarantee cat shelter in the Pacific Northwest. We offer adoption, foster care, and veterinary services ...","additional_links":[{"text":"Cat Adoption Team | Sherwood Cat Rescue | Cat Adoption ...","href":""}],"cite":{}}],"image_results":[],"total":4140000000,"answers":["Do cats fart?","What two animals make a cat?","Why do cats hate water?","Is a cat good pet?"],"ts":2.605560064315796,"device_region":"US","device_type":"desktop"}

So how can I get & list the values of these? I will be very happy if someone can help me with this. I’m begginer with json values :/


You are returning an array of arrays. You need to access them using an index


Answered By – joeb

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published