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? 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'; } ?> 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 '#' 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) Link to comment https://forums.phpfreaks.com/topic/50102-strange-short/#findComment-246024 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.