How can the SPL (Standard PHP Library) be used to convert XML data to an array in PHP?
To convert XML data to an array in PHP, you can use the SimpleXML extension provided by the SPL (Standard PHP Library). SimpleXML allows you to easily parse and manipulate XML data in PHP. By loading the XML data into a SimpleXMLElement object, you can then convert it to an array using the json_decode function. This allows you to work with the XML data as an array in your PHP code.
$xmlString = '<data><item>First item</item><item>Second item</item></data>';
$xml = simplexml_load_string($xmlString);
$json = json_encode($xml);
$array = json_decode($json, true);
print_r($array);