I am trying to convert xml to json in php. If I do a simple convert using simple xml and json_encode none of the attributes in the xml show.
$xml = simplexml
Looks like the $state->name variable is holding an array. You can use
$state->name
var_dump($state)
inside the foreach to test that.
foreach
If that's the case, you can change the line inside the foreach to
$states[]= array('state' => array_shift($state->name));
to correct it.