for an easy xml structure you can use something like this
$xml = '<users>
<user>
<firstname>1</firstname>
<lastname>2</lastname>
<username>3</username>
<password>4</password>
</user>
<user>
<firstname>5</firstname>
<lastname>6</lastname>
<username>7</username>
<password>8</password>
</user>
</users>';
$input_xml = simplexml_load_string($xml); // load the xml string
$json = json_encode($input_xml); // convert to json object
$output_array = json_decode($json, TRUE); // decode the json and transform to an array
hope it helps