0

I am trying to compare strings but I always get false. I tried to use var_dump on both values but they are 2 different lengths. I have seen this question has been asked many times but not sure how to resolve this.

$nameid = $as->getAuthData('saml:sp:NameID');
$luser = $nameid;

$loguser = strtolower($luser);
var_dump($loguser);
// this returns string(167) "test1.test@comtest.com"
$arr = array('test1.test@comtest.com', 'test2.test@comtest.com');

 foreach ($arr as $value) 
 {
    var_dump($value);
    //this returns string(28) "test1.test@comtest.com"
    if ($test == $value)
    {
       echo('success');
       break;
     }        
 }  

I see this following markup in the View Source: I am not sure how do to get this value from this XML.

<saml:nameid xmlns:saml="urn:oasis:names:tc:saml:2.0:assertion" format="urn:oasis:names:tc:saml:2.0:nameid-format:transient">test1.test@comtest.com</saml:nameid>
nav100
  • 2,923
  • 19
  • 51
  • 89
  • *"I have seen this question has been asked many times"* - It might be a good idea to link to one of those places, so we can help you interpret the answers there instead of having to write it from scratch (or close it as duplicate). – GolezTrol Jun 06 '18 at 15:25
  • https://stackoverflow.com/questions/642438/how-can-i-remove-the-null-character-from-string/642475#642475 – nav100 Jun 06 '18 at 15:27
  • also tried strcmp() function – nav100 Jun 06 '18 at 15:29
  • I see the following XML elements in the view source. string(167) "test1.test@comtest.com" – nav100 Jun 06 '18 at 16:20
  • Well, there is your problem. `test1.test@comtest.com` !== `test1.test@comtest.com` – GolezTrol Jun 06 '18 at 19:10

0 Answers0