Mantis - Quercus
Viewing Issue Advanced Details
3127 major always 12-05-08 23:11 12-10-08 09:14
koreth  
nam  
normal  
closed 3.2.1  
fixed  
none    
none 4.0.0  
0003127: array_chunk() uses keys instead of values in result
<?php
$x = array_chunk(array(1 => 12345, 2 => 34567, 3 => 56789), 3);
print_r($x);

Vanilla PHP prints

Array
(
    [0] => Array
        (
            [0] => 12345
            [1] => 34567
            [2] => 56789
        )

)

Quercus prints

Array
(
    [0] => Array
        (
            [0] => 1
            [1] => 2
            [2] => 3
        )

)

Notes
(0003578)
koreth   
12-05-08 23:13   
Trivial fix:

--- a/modules/quercus/src/com/caucho/quercus/lib/ArrayModule.java
+++ b/modules/quercus/src/com/caucho/quercus/lib/ArrayModule.java
@@ -198,7 +198,7 @@ public class ArrayModule
     int i = 0;
     for (Map.Entry<Value, Value> entry : array.entrySet()) {
       Value key = entry.getKey();
- Value value = entry.getKey();
+ Value value = entry.getValue();
 
       if (i % size == 0) {
         currentArray = new ArrayValueImpl();
(0003588)
nam   
12-10-08 09:14   
php/1715