How do I parse and build JSON/XML/CSV?

Parsing and Building Data Formats

Keywords: JSON, XML, CSV, Parsing, Building, PHP
Description: This page explains how to parse and build JSON, XML, and CSV formats using PHP.
<?php // Example of parsing and building JSON in PHP // Parsing JSON $jsonString = '{"name":"John", "age":30, "city":"New York"}'; $jsonData = json_decode($jsonString, true); echo "Name: " . $jsonData['name'] . "<br>"; // Building JSON $data = array("name" => "Jane", "age" => 25, "city" => "Los Angeles"); $jsonOutput = json_encode($data); echo "JSON Output: " . $jsonOutput; ?>

Keywords: JSON XML CSV Parsing Building PHP