play_ Posted May 5, 2007 Share Posted May 5, 2007 <?php $text = "# hello world"; $text = explode(' ', $text); $c = current($text); echo $c; ?> This returns: "#". so $c is '#'. But if i do this: if( $c == "#" ) { echo 'test'; } it returns nothing. why? Quote Link to comment https://forums.phpfreaks.com/topic/50102-strange-short/ Share on other sites More sharing options...
MadTechie Posted May 5, 2007 Share Posted May 5, 2007 erm.. worked for me <?php $text = "# hello world"; $text = explode(' ', $text); $c = current($text); if( $c == "#" ) { echo 'test'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/50102-strange-short/#findComment-246017 Share on other sites More sharing options...
play_ Posted May 5, 2007 Author Share Posted May 5, 2007 Ahh many sorry. i actually had $text = " # hello world"; so i guess current was a \n? but strange how when echoed, it echoed '#' Quote Link to comment https://forums.phpfreaks.com/topic/50102-strange-short/#findComment-246021 Share on other sites More sharing options...
MadTechie Posted May 5, 2007 Share Posted May 5, 2007 my test was echo "~$c~" so if a newline appeared i would get ~ #~ easy mistake to make (been their got all the t-shirts) Quote Link to comment https://forums.phpfreaks.com/topic/50102-strange-short/#findComment-246024 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.