I am having trouble understanding the proper syntax to print array results using the SimpleXMLElement. From my xml result i must ask the user to match themselves with one of the people found in the array, and am not sure what is the best way to do this.
Sample XML result:
[authentication] => SimpleXMLElement Object
(
[age] => SimpleXMLElement Object
(
[code] => 5
[ambiguous] => SimpleXMLElement Object
(
[person] => Array
(
[0] => SimpleXMLElement Object
(
[name] => Paul Foreman
[question] => SimpleXMLElement Object
(
[id] => dcalc3
[prompt] => What+do+the+%3Cb%3Elast+four%3C%2Fb%3E+digits+of+your+Social+Security+Number+add+up+to%3F
[answer] => 5
)
)
[1] => SimpleXMLElement Object
(
[name] => Paul Foreman
[question] => SimpleXMLElement Object
(
[id] => dcalc3
[prompt] => What+do+the+%3Cb%3Elast+four%3C%2Fb%3E+digits+of+your+Social+Security+Number+add+up+to%3F
[answer] => 6
)
)
)
)
)
)
Solution im looking for:
<?php
$string = $xml_result;
$xml = new SimpleXMLElement($string);
$is_age_code = $xml->authentication->{'age'}->code;
if($x_is_age_code == '5'){
// code 5 means more than one match found
// Ask user verification question
// If answer matches question
// Set current user as that person
}
?>
How can i find out how many 'Persons' are in the array and identify them with a number?