

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 Questions & Answers
- PHP foreach Loop.
- Parsing array of objects inside an object using maps or forEach using JavaScript?
- What is JSON parsing in Rest Assured?
- Performance of FOR vs FOREACH in PHP
- Calling Stored Procedure inside foreach PHP Codeigniter
- Multiple index variables in PHP foreach loop
- Difference Between For and Foreach in PHP
- Stripping last comma from a foreach loop in PHP?
- PHP Casting Variable as Object type in foreach Loop
- Parsing SAP Logon ticket with .NET
- Foreach loop with two arrays and if-condition evaluation to find matching values PHP?
- Create nested JSON object in PHP?
- Convert JSON array into normal json in JavaScript
- Converting JSONL to Array with PHP
- Parsing XML with SAX APIs in Python
Advertisements