RE: Removing an element from the middle of an mdlti-dimentsional array

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

 



array_splice($a, 1, 1);

This will remove the second element, and reset the keys.



Simcha Younger

-----Original Message-----
From: Don [mailto:don@xxxxxxxxxxxxx] 
Sent: Friday, August 15, 2008 4:30 AM
To: php-general@xxxxxxxxxxxxx
Subject:  Removing an element from the middle of an mdlti-dimentsional
array

Hi,

Let's say I have the following array:

$myArray = array(array('1','2','3'), array('4','5','6'), array('7','8','9'),

array('10','11','12'));

How do I remove say the second element?

I have tried: $myArray = array_splice($myArray, 1, 1);

But this seems to remove the second element as well as all the following 
elements and I am left with:

$myArray = array(array('1','2','3'));

when I really want:

$myArray = array(array('1','2','3'), array('7','8','9'), 
array('10','11','12'));


Thanks,
Don 



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

No virus found in this incoming message.
Checked by AVG - http://www.avg.com 
Version: 8.0.138 / Virus Database: 270.6.3/1612 - Release Date: 14/08/2008
18:03


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