Problem with if statement that should return true

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
oskare100
Forum Commoner
Posts: 80
Joined: Sun Oct 29, 2006 5:47 am

Problem with if statement that should return true

Post 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]
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

There's usually a semicolon after an HTML entity: »
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Post by markusn00b »

try changing $RAQUO to &raquo

Last i heard uppercase != lowercase

:P

Hope this helps.
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post 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
Last edited by vigge89 on Wed Dec 26, 2007 12:55 pm, edited 1 time in total.
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Post 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.
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post 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 ;)
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Post 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:
Post Reply