Newbie in PHP.
I’m getting a value of an array index in my variable as $acc_type = $cur_account['roles']
I’m printing the output by echo $acc_type and it prints administrator on screen.
So, if I tried echo strcmp("administrator", $acc_type); and it should ideally print 0, but it isn’t; instead it is printing 1.
I’m not able to understand why this happens. Do I need to do a typecast or something? Where am I going wrong?
Try printing the content of your variable using
var_dumpto see whystrcmpdoes not return0.var_dumpwill print the quoted string as well as the length, which helps finding white space characters or whatever prevents the string from being equal.