note 41146 added to language.operators.increment
| From: | php-general at lists dot php dot net | Date: | Wed, 31 Mar 2004 18:19:27 +0000 |
| Subject: | note 41146 added to language.operators.increment | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-67426@lists.php.net to get a copy of this message | ||
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..
----
Manual Page -- http://www.php.net/manual/en/language.operators.increment.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41146
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41146&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41146&report=yes
Search -- http://master.php.net/manage/user-notes.php