$layer is my array -
         $currPos = array_search($HTTP_POST_VARS["selLayer"], $layer);
         $arrB = array_slice($layer, $currPos);
         $val  = array_shift($arrB);
         $arrA = array_slice($layer, 0, $currPos);
         $layer = array_merge($arrA, $arrB);
         // I do this to change the position of the element actually
         // so you can comment this out
         // array_unshift($layer, $val);
It's little memory expensive since it will create two more arrays but you
can use unset or something to delete them, will work inside a function.


> No. :-)
>
> What I've had to do is add a dummy value, unset($array[4]) and then array_pop the 
>dummy value off
> the array to get it out of there completely. The reason: unset will only remove 
>$array[4]'s value,
> not the key.
>
> There are plenty of other ways I'm sure, but simply unsetting has really messed me 
>up on occasion.
> I'll unset a value and then implode my array (say a list of numbers), and end up 
>with a string like
> so:
>
> 1,233,642,,234,5632,
>
> Where I've unset the 4th and last keys. Which of course really messes up and explode.
>
> # Nathan
>
> ----- Original Message -----
> From: "Liam Gibbs" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, April 25, 2002 1:22 PM
> Subject: [PHP] Array function to delete
>
>
> I've been checking the PHP documentation, but can't
> find a function that will delete a member of an array,
> like such:
>
> $a = array(1, 2, 3, 4, 5);
>
> Use the function, say array_delete($a, 3); and that
> will delete the third member in the array (which would
> be 4 above), so that the array would contain 1, 2, 3,
> 5.
>
> Is there such a function?
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Games - play chess, backgammon, pool and more
> http://games.yahoo.com/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

-Pushkar S. Pradhan


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

Reply via email to