“PHP XML a JSON” Código de respuesta

PHP XML a 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);
Frail Frog

PHP XML a JSON

foreach($xml->children() as $state)
{
    $states[]= array('state' => (string)$state->name); 
}       
echo json_encode($states);
Frail Frog

Respuestas similares a “PHP XML a JSON”

Preguntas similares a “PHP XML a JSON”

Más respuestas relacionadas con “PHP XML a JSON” en PHP

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código