What is the function of simplexml_load_string() in parsing XML data in PHP?

simplexml_load_string() is a PHP function used to parse XML data from a string and create a SimpleXMLElement object that can be easily traversed and manipulated. This function is useful when you have XML data in string format and need to extract information from it in your PHP code.

$xmlString = '<example><item>Apple</item><item>Orange</item></example>';
$xml = simplexml_load_string($xmlString);

foreach ($xml->item as $item) {
    echo $item . "<br>";
}