XML and JSON Parsing in PHP
PHP provides built-in functions to parse XML and JSON data. These functions can be used to extract data from XML and JSON files and convert them into PHP arrays or objects.
Example:
php
// parse an XML file
$xml = simplexml_load_file("example.xml");
echo $xml->title;
// parse a JSON string
$json = '{"name": "John", "age": 30}';
$obj = json_decode($json);
echo $obj->name;
No comments:
Post a Comment