ran into a seemingly odd problem

From: Date: Sat, 10 Sep 2005 21:17:06 +0000
Subject: ran into a seemingly odd problem
Groups: php.general 
Request: Send a blank email to php-general+get-222123@lists.php.net to get a copy of this message
Hello all. I am new to this list but not to new to php although maybe the problem I am having will prove otherwise ok, I am writing a server(or trying to), Basically I am attempting to write a chat type server in php. I cant seem to get it to realize that I have typed more than one word, so execute the code within the if statement. basic function is below, well what I am attempting to do anyway, I have the str_word_count() defined as $word_count and $words for the array of words that str_word_count($variable, 1) creates ok, little piece of code is below function commands($sock, $data) { $word_count = str_word_count($data); $words = str_word_count($data, 1); /* here is where the problems come in I think */ if(($word_count == 2) && ($data == '.quit')) { echo "you quit with a message of $data\n"; } else { echo "quitting without saying anything...\n"; } } it seems like the code fragment above does absolutely nothing e.g $word_count reverts to being empty once the if statement is hit. if I put something in the function, but outside of the if statement like echo "word_count was $word_count\n"; that works fine and returns an integer like it should am I the only one who finds this little thing odd or am I missing something that it is so simple it already sticks out to others as a big glaring error? any ideas? matt

« previous php.general (#222123) next »