Answers for "php xml to json"

PHP
0

php xml to json

$fileContents= file_get_contents($url);

$fileContents = str_replace(array("n", "r", "t"), '', $fileContents);

$fileContents = trim(str_replace('"', "'", $fileContents));

$simpleXml = simplexml_load_string($fileContents);

$json = json_encode($simpleXml);
Posted by: Guest on February-05-2022
0

php xml to json

foreach($xml->children() as $state)
{
    $states[]= array('state' => (string)$state->name); 
}       
echo json_encode($states);
Posted by: Guest on February-05-2022

Browse Popular Code Answers by Language