Edit report at https://bugs.php.net/bug.php?id=64192&edit=1

 ID:                 64192
 Updated by:         larue...@php.net
 Reported by:        italopaesano at gmail dot com
 Summary:            function array_splice() wrong result
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            *General Issues
 Operating System:   linux
 PHP Version:        5.3.21
 Block user comment: N
 Private report:     N

 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

the replacement is an array, and the elements are insert into the gap one by 
one.

for you need, you should change the $stripe to:
$strip = array(
    array(
          'start' => array('day' => '11','month '=> '1'),
          'end'   => array('day'=> '14','month'=> '1')),
);


Previous Comments:
------------------------------------------------------------------------
[2013-02-12 00:20:26] italopaesano at gmail dot com

Description:
------------
function array_splice()

 return wrong result when splice multidimensional array.
i hope that the attached script is clear.
sorry for my english.

Test script:
---------------
$a = array();
$a[] = array(
          'start' => array('day' => '1','month '=> '2'),
          'end'   => array('day'=> '3','month'=> '2'));
$a[] = array(
          'start' => array('day' => '1','month '=> '3'),
          'end'   => array('day'=> '3','month'=> '3'));

$strip = array(
          'start' => array('day' => '11','month '=> '1'),
          'end'   => array('day'=> '14','month'=> '1'));

array_splice($a, 0, 1, $strip);

$temp = print_r($a,TRUE);  
$temp = str_replace("\n", '<br>', $temp);
echo str_replace(" ", "&nbsp;",$temp);

Expected result:
----------------
Array
(
    [0] => Array
        (
            [start] => Array
                (
                    [day] => 11
                    [month ] => 1
                )

            [end] => Array
                (
                    [day] => 14
                    [month] => 1
                )

        )

    [1] => Array
        (
            [start] => Array
                (
                    [day] => 1
                    [month ] => 3
                )

            [end] => Array
                (
                    [day] => 3
                    [month] => 3
                )

        )

)

Actual result:
--------------
Array
(
    [0] => Array
        (
            [day] => 11
            [month ] => 1
        )

    [1] => Array
        (
            [day] => 14
            [month] => 1
        )

    [2] => Array
        (
            [start] => Array
                (
                    [day] => 1
                    [month ] => 3
                )

            [end] => Array
                (
                    [day] => 3
                    [month] => 3
                )

        )

)


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=64192&edit=1

Reply via email to