I have an XML file that I need to loop through and check for a string match. Not sure why the code below isn't working, i.e. does not return "true".
XML
<AUTHORIZED>
<USER>janedoe</USER>
<USER>sallysmith</USER>
<USER>walterwilliams</USER>
<USER>jennyjones</USER>
</AUTHORIZED>
PHP
<?php
$user = 'janedoe';
//Load xml file
if (file_exists('users.xml')) {
$authUsers = simplexml_load_file('users.xml');
} else {
echo 'Could not find list of authorized users!';
}
//Check for approved user
if(in_array($user, $authUsers)){
$approvedUser = 'true';
} else {
$approvedUser = 'false';
}
echo $approvedUser;
?>
var_dumpon$approvedUser. I don't think it is structured like you think it is.var_dump($approvedUser)yields:string(5) "false"