Array Functions

Discussion in 'PHP' started by shiva_rnm, Jul 11, 2008.

  1. #1
    Hi All,

    I have file with only arrays which are many of different size.

    is it possible to make array modification provided the array name, index and value like inserting, deleting and updating.
    Say,
    <?

    // Comment1
    $arr1 = array(
    "index1" => "bus",
    "index2" => "aus"
    );

    if i specify to delete index1 then array shud be...

    <?

    // Comment1
    $arr1 = array(
    "index2" => "aus"
    );


    I have done this making use of the string functions . but i want to know is there built functions to do all that.

    Thanks
     
    shiva_rnm, Jul 11, 2008 IP
  2. revvi

    revvi Peon

    Messages:
    58
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    use this:

    unset($arr1['index1']);
    PHP:
     
    revvi, Jul 11, 2008 IP
  3. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #3
    Sorry, didn't see the post above when I posted.

    I might as well leave in what I posted anyway

    <?php unset($arr1['index1']); ?>
    PHP:
     
    Danltn, Jul 11, 2008 IP
  4. shiva_rnm

    shiva_rnm Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    thanks for reply....

    I forgot to tell that set of array's are present in a separate file. So i'm making array modification in another php file.

    what i did is i converted the array's php file into string then used string function to make array modification.
     
    shiva_rnm, Jul 11, 2008 IP