Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2002
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Remove Member from Array

    Is there a built in function that will remove a member from an array or should I build my own?

    Ryan

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There is. It's called unset().

    PHP Code:
    $foo = array('apple''pear''mango');
    unset(
    $foo[1]);
    var_dump($foo); 
    Watch out if you intend to iterate over the modified array, because unset() does not cause it to re-index itself. Use $foo = array_values($foo) or a foreach-loop instead. With associative arrays, you don't have this problem.
    De gustibus non est disputandum.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •