removing an item from an array

Posted on 2006-05-16
Last Modified: 2008-02-26
How do you remove an item from an array?

Question by:weikelbob
    LVL 16

    Accepted Solution

    $d = array(1,5,6,8,9,33,44,66);

    array_splice($d, 2 , 3); //remove elements from position 2and delete 3 elements. it re-arranges the array, if u ommit the length to delete (3 in our example), it will delete from position 2 to the end of the array


    you can use
    unset($d[2]) to remove item with index 2, but the deleted item will leave a vacant place
    LVL 7

    Author Comment

    Got this, thanks dr. dedo

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Join & Write a Comment

    Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
    These days socially coordinated efforts have turned into a critical requirement for enterprises.
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now