how to change a value inside an array ?

Discussion in 'PHP' started by ramysarwat, May 8, 2010.

  1. #1
    how to change a value inside an array ?
     
    ramysarwat, May 8, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    <?php
    $my_array = array('hey' => 'man');
    //change man to girl...
    $my_array['hey'] = 'girl';
    print_r($my_array);
    ?>
    PHP:
     
    danx10, May 8, 2010 IP
  3. m-1o

    m-1o Guest

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    He also said danx10
     
    m-1o, May 8, 2010 IP
  4. gapz101

    gapz101 Well-Known Member

    Messages:
    524
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    150
    #4
    that is if you have a key, if not you have to search the key of that value :p
     
    gapz101, May 11, 2010 IP
  5. musicmasteria

    musicmasteria Peon

    Messages:
    33
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    musicmasteria, May 11, 2010 IP
  6. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #6
    refer the php.net manual as said by music
    It will teach you
    Else have a look in w3schools
     
    roopajyothi, May 12, 2010 IP
  7. jaikanth12

    jaikanth12 Guest

    Messages:
    119
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    An array in PHP is actually an ordered map. A map is a type that associates values to keys. This type is optimized for several different uses; it can be treated as an array, list (vector), hash table (an implementation of a map), dictionary, collection, stack, queue, and probably more. As array values can be other array s, trees and multidimensional array s are also possible.


    Please visit this site for knowing better information about PHP: http://php.net/manual/en/language.types.array.php
     
    jaikanth12, May 13, 2010 IP