RE: [PHP] [BUG?] substr giving strange results

From: Date: Tue, 09 Oct 2001 13:51:03 +0000
Subject: RE: [PHP] [BUG?] substr giving strange results
Groups: php.general 
Request: Send a blank email to php-general+get-70474@lists.php.net to get a copy of this message
look at what you've typed, and look at the manual for substr() the args for substr() are (string, start, length) in the $YY call you specified to extract 3 characters from $comp, not 4. and likewise for the subsequent calls - the third argument in the brackets after substr( is the number of characters to extract. It's in the manual :-) Cheers Dave -----Original Message----- From: Jean-Christian Imbeault [mailto:jean_christian@hotmail.com] Sent: 09 October 2001 14:54 To: php-general@lists.php.net Subject: [PHP] [BUG?] substr giving strange results Ok, either I missed something really simple or ... Here's the code: $comp = trim($data->comp); $YY = substr($comp,0,3); $MM = substr($comp,5,6); $DD = substr($comp,8,9); echo "COMP is $comp<BR>"; echo "DATE is $YY" . "," . "$MM" . "," . $DD; The results are: COMP is 2002-10-29 DATE is 200,10-29,29 Now, shouldn't it be: COMP is 2002-10-29 DATE is 2002,10,29 This exact code snippet works fine one another page but not this one ... What is the obvious thing I am not seeing? Jc _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#70474) next »