Page 1 of 1

Problem with if statement that should return true

Posted: Wed Dec 26, 2007 12:39 pm
by oskare100
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hello,
This is the code snippet:

Code: Select all

$breadcrumbtrail = $breadcrumb->trail(' » ');
$breadcrumbexploded = explode(";", $breadcrumbtrail);
echo $breadcrumbexploded[0];
if ($breadcrumbexploded[0] == "&RAQUO") {
echo "true";
} else {
echo "false";
}
That code returns the text "&RAQUOfalse" but it should return "&RAQUOtrue" since $breadcrumbexploded[0] == "&RAQUO". I can't figure out why it can't understand that $breadcrumbexploded[0] actuallt is &RAQUO.

Best Regards
Oskar R


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Wed Dec 26, 2007 12:49 pm
by Kieran Huggins
There's usually a semicolon after an HTML entity: »

Posted: Wed Dec 26, 2007 12:50 pm
by markusn00b
try changing $RAQUO to &raquo

Last i heard uppercase != lowercase

:P

Hope this helps.

Posted: Wed Dec 26, 2007 12:53 pm
by vigge89
"&RAQUO" is not the same as "&raquo", you will have to convert the string to either lowercase or uppercase before comparing (strtoupper()/strtolower()) or compare case-insensitive with strcasecmp().

Edit: Three replies, that's what you get for replying without refreshing the page first :p

Posted: Wed Dec 26, 2007 12:53 pm
by markusn00b
vigge89 wrote:"&RAQUO" is not the same as "&raquo", you will have to convert the string to either lowercase or uppercase before comparing (strtoupper()/strtolower()).
You so took my idea!

I want a court to settle this.

Posted: Wed Dec 26, 2007 12:57 pm
by vigge89
markusn00b wrote:
vigge89 wrote:"&RAQUO" is not the same as "&raquo", you will have to convert the string to either lowercase or uppercase before comparing (strtoupper()/strtolower()).
You so took my idea!

I want a court to settle this.
Heh, I win since you wrote $RAQUO instead of &RAQUO ;)

Posted: Wed Dec 26, 2007 1:08 pm
by markusn00b
vigge89 wrote:
markusn00b wrote:
vigge89 wrote:"&RAQUO" is not the same as "&raquo", you will have to convert the string to either lowercase or uppercase before comparing (strtoupper()/strtolower()).
You so took my idea!

I want a court to settle this.
Heh, I win since you wrote $RAQUO instead of &RAQUO ;)
GOD DAMMIT

:oops: