On Fri, 7 Aug 2009 17:06:45 -0600, John Butler wrote:

> 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


  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

array(2) {
  array(3) {
    string(1) "a"
    string(1) "b"
    string(1) "c"
  array(2) {

When I first looked into array_slice, I was hoping that it
could be used to extract a "column" from a multi-dimensional
array, e.g.:

  array_slice ($a1, 1)

would result in:

  array (2, 'b', false)

This would be very useful at times, but doesn't seem
to be possible.


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

Reply via email to