Ads removed from the pastie. \o/
Running costs stayed. :-(
Donations welcome!
Bitcoin: |
1QC38uPBSy7WSYz1whM5SYTHAdhqkN6o8V |
Ethereum: |
0x0855778a6181a69cc7d5d08c71c4f5846010eb67 |
Verge: |
D8fo1fszrNmUK4kfQW5owhYMv3osPvgn2g |
Paste ID: |
# b2nsd |
Date posted: |
Sat, 18 Feb 2012 00:12:04 +0000 |
Date of expiration: |
never (permanent entry) |
Description: |
Screw up []-operator for array in PHP |
<?php
/**From the docs: http://de.php.net/manual/de/language.types.array.php
* Section: Creating/modifying with square bracket syntax
* Box: Note:
*
* "As mentioned above, if no key is specified, the maximum
* of the existing integer indices is taken, and the new
* key will be that maximum value plus 1."
*
*
* The problem with the above is, that if that maximum index was MAX_INT
* the []-operator gets screwed.
*/
$arr[] = 'foo';
$arr[ PHP_INT_MAX ] = 'bar';
$arr[] = 'fail'; // Warning: Cannot add element to the array as the next element is already occupied in ...
/**Output (64-bit):
*
* <br />
* <b>Warning</b>: Cannot add element to the array as the next element is already occupied in ...
* Array
* (
* [0] => foo
* [9223372036854775807] => bar
* )
*/
?>