note 41146 deleted from language.operators.increment by hholzgra

From: Date: Thu, 02 Aug 2012 15:21:07 +0000
Subject: note 41146 deleted from language.operators.increment by hholzgra
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-189850@lists.php.net to get a copy of this message
Note Submitter: ---- Note that incrementing strings can give unpredictable results due to type changes. For example: <?php $i = '9C6'; for($n=0; $n<10; $n++) echo ++$i . "\n"; ?> Gives you: 9C7 9C8 9C9 9D0 10 11 12 ..etc. The 'D' (and also 'E') characters are interpreted here as exponents of 10 (i.e., scientific notation) formatted numbers. Using '9D6' will give 9000001, 9000002, etc. You might want to use all alphabetical or all numerical, but not mix the two otherwise you may not get what you expect..

« previous php.notes (#189850) next »