- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Parsing JSON array with PHP foreach
The below code can be used to parse JSON array −
Example
<?php $json_array ='{ "values": { "a": "abc", "d": 0, "efg": 349 } }'; $array = json_decode($json_array, true); foreach($array as $values) { echo $values['efg']; echo $values['d']; echo $values['a']; }
Output
This will produce the following output −
3490abc
- Related Articles
- Parsing array of objects inside an object using maps or forEach using JavaScript?
- PHP foreach Loop.
- What is JSON parsing in Rest Assured?
- Calling Stored Procedure inside foreach PHP Codeigniter
- Multiple index variables in PHP foreach loop
- Performance of FOR vs FOREACH in PHP
- Difference Between For and Foreach in PHP
- Foreach loop with two arrays and if-condition evaluation to find matching values PHP?
- Stripping last comma from a foreach loop in PHP?
- PHP Casting Variable as Object type in foreach Loop
- The internal working of the ‘foreach’ loop in PHP
- How to count values from a PHP array and show value only once in a foreach loop?
- Create nested JSON object in PHP?
- Convert JSON array into normal json in JavaScript
- Converting JSONL to Array with PHP

Advertisements