How to make two dimensional array's value blank?

Discussion in 'PHP' started by computerzworld, Dec 24, 2007.

  1. #1
    Hello. I want to make two dimensional array's value blank. How can I do this? For example $email[1]['name']. I want that $email Array should have blank value. Thanks in advance.
     
    computerzworld, Dec 24, 2007 IP
  2. falcondriver

    falcondriver Well-Known Member

    Messages:
    963
    Likes Received:
    47
    Best Answers:
    0
    Trophy Points:
    145
    #2
    $email[1]['name'] = "";
     
    falcondriver, Dec 24, 2007 IP
  3. Vio82

    Vio82 Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    just use blank key []

    $email[]['name'] = '';
    $email[]['name'] = '';
    $email[]['name'] = '';
     
    Vio82, Dec 24, 2007 IP
  4. elitecoder

    elitecoder Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    If you want a function to handle it all, I wrote this:

    function array_update($array) {

    foreach($array as $key => $value) {

    if (is_array($array[$key]))
    $array[$key] = array_update($array[$key]);
    else
    $array[$key] = '';

    }

    return $array;
    }
     
    elitecoder, Dec 24, 2007 IP