ID: 41686 Updated by: [EMAIL PROTECTED] Reported By: rele at gmx dot de -Status: Open +Status: Closed Bug Type: Scripting Engine problem Operating System: Windows XP SP2 PHP Version: 5.2.3 New Comment:
This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2007-06-14 15:14:20] rele at gmx dot de I could reproduce the same result with PHP 5.2.1 on SuSE Linux Enterprise Server 9. ------------------------------------------------------------------------ [2007-06-14 10:10:31] rele at gmx dot de Description: ------------ array_slice supports omitting of the $length parameter only if you pass just the first two parameters (params 1 and 2), but passing the default value NULL when you want to set $preserve_keys to TRUE (params 1, 2, 3 and 4) does not work. This would be especially useful for associative arrays. Reproduce code: --------------- $a = array(1,2,3); $b = array('a'=>1,'b'=>1,'c'=>2); var_dump(array_slice($a, 1), array_slice($a, 1, 2, TRUE), array_slice($a, 1, NULL, TRUE), array_slice($b, 1), array_slice($b, 1, 2, TRUE), array_slice($b, 1, NULL, TRUE)); Expected result: ---------------- array(2) { [0]=> int(2) [1]=> int(3) } array(2) { [1]=> int(2) [2]=> int(3) } array(2) { [1]=> int(2) [2]=> int(3) } array(2) { ["b"]=> int(1) ["c"]=> int(2) } array(2) { ["b"]=> int(1) ["c"]=> int(2) } array(2) { ["b"]=> int(1) ["c"]=> int(2) } Actual result: -------------- array(2) { [0]=> int(2) [1]=> int(3) } array(2) { [1]=> int(2) [2]=> int(3) } array(0) { } array(2) { ["b"]=> int(1) ["c"]=> int(2) } array(2) { ["b"]=> int(1) ["c"]=> int(2) } array(0) { } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41686&edit=1
