need to trim one slice from a multidimensional array
Posted: Fri Jun 27, 2008 12:41 am
Hi there,
I have what I think is probably a pretty simple question. I have a multi-dimensional array stored in a session, and I need to be able to delete the values for one particular slot in that array.
For example, if my array looks like:
then I might need to delete the values in, say, the second slot:
What I was sorta thinking was that if I could bump that sub-array to the beginning of the main $_SESSION['myarray'] array, then I could use array_shift() to remove it and its values. I just haven't been able to find a php function that would allow me to specify a particular slot in the array and move it to the top.
I hope this makes sense.
Any input will be VERY appreciated!
I have what I think is probably a pretty simple question. I have a multi-dimensional array stored in a session, and I need to be able to delete the values for one particular slot in that array.
For example, if my array looks like:
Code: Select all
$_SESSION['myarray'] = array(
array(x=>'123', y=>'456', z=>'789'),
array(x=>'abc', y=>'def', z=>'ghi'),
array(x=>'red', y=>'green', z=>'blue'),
array(x=>'etc', y=>'etc', z=>'etc')
);Code: Select all
array(x=>'abc', y=>'def', z=>'ghi')I hope this makes sense.
Any input will be VERY appreciated!