Link to home
Start Free TrialLog in
Avatar of interclubs
interclubs

asked on

Replace item in array (php)

Let's say I have an array like this:

array(
name=>'sam',
age=>'22',
weight=>'222'
)

How can I update the name element in the array? to set it to 'John' for example....
ASKER CERTIFIED SOLUTION
Avatar of gr8gonzo
gr8gonzo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The online manual might be helpful for these sorts of questions.  For example, if you wanted to know if "sam" was in the array, you could use in_array()
http://us.php.net/manual/en/function.in-array.php

if (in_array('sam', $my_array)) echo "We found Sam!";

The complete list of array functions is here:
http://us.php.net/manual/en/ref.array.php

HTH, ~Ray