Re: Re: does array_slice not work on multidimensional arrays?

From: Date: Sat, 08 Aug 2009 14:29:36 +0000
Subject: Re: Re: does array_slice not work on multidimensional arrays?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-296474@lists.php.net to get a copy of this message
does array_slice not work on multidimensional arrays? I have one multidimensional array, and when I run it thru' array_slice() nothing happens, that I can tell. If it does not work on multidimensional arrays, what is the *simplest* workaround? (I am already working past what was budgeted for this this script.. so I really want to avoid anything but the most newbie of hacks to achieve this.) //PHP Version 4.3.9
Works for me in PHP 5: ----
cat a.php
<?php echo phpversion(), "\n"; $a1 = array (array (1,2,3,4), array ('a','b','c'), array (true, false)); $a2 = array_slice ($a1, 1, 2); var_dump ($a2);
php5 a.php
5.2.5 array(2) { [0]=> array(3) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" } [1]=> array(2) { [0]=> bool(true) [1]=> bool(false) } }
It seems clear to me, but do you also agree that my evidence is that array_slice() does NOT work on multi-dimmed arrays on v.4.3.9? Here is the evidence: this: var_dump($BuildPerUniqueDateArray); echo"\n\n~~~~~~~~~~~~~\n\n"; array_slice($BuildPerUniqueDateArray, 1, 2); var_dump($BuildPerUniqueDateArray); returns: array(12) { ["2009-08-08"]=> array(2) {
    ["t7solar_landing"]=>
    string(1) "2"
    ["aweber_7solar_aw"]=>
    string(1) "1"
} ["2009-08-07"]=> array(3) {
    ["t7solar_landing"]=>
    string(1) "2"
    ["aweber_7solar_aw"]=>
    string(1) "1"
    ["aweber_7solar_confirm"]=>
    string(1) "1"
} ["2009-08-06"]=> array(3) {
    ["aweber_7solar_confirm"]=>
    string(1) "5"
    ["t7solar_landing"]=>
    string(1) "6"
    ["aweber_7solar_aw"]=>
    string(1) "3"
} ["2009-08-05"]=> array(3) {
    ["aweber_7solar_confirm"]=>
    string(1) "1"
    ["t7solar_landing"]=>
    string(1) "3"
    ["aweber_7solar_aw"]=>
    string(1) "4"
} ... ~~~~~~~~~~~~~ array(12) { ["2009-08-08"]=> array(2) {
    ["t7solar_landing"]=>
    string(1) "2"
    ["aweber_7solar_aw"]=>
    string(1) "1"
} ["2009-08-07"]=> array(3) {
    ["t7solar_landing"]=>
    string(1) "2"
    ["aweber_7solar_aw"]=>
    string(1) "1"
    ["aweber_7solar_confirm"]=>
    string(1) "1"
} ["2009-08-06"]=> array(3) {
    ["aweber_7solar_confirm"]=>
    string(1) "5"
    ["t7solar_landing"]=>
    string(1) "6"
    ["aweber_7solar_aw"]=>
    string(1) "3"
} ["2009-08-05"]=> array(3) {
    ["aweber_7solar_confirm"]=>
    string(1) "1"
    ["t7solar_landing"]=>
    string(1) "3"
    ["aweber_7solar_aw"]=>
    string(1) "4"
} ... ------------ John Butler (Govinda) govinda.webdnatalk@gmail.com

« previous php.general (#296474) next »