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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux