Can any body pls. help me...here's my problem.. How will I append another value in a associative array using foreach? let say i have this array with a value. $words = array($x => array($rand_cell_number,$direction)); PHP: any help will greatly appreciated. thanks in advance!
You may have already figured this out by now. But, if not, see if this helps. Because you want to use foreach, I assume you already have your data in simple arrays, and you want to combined them into a single multi-dimensional array. Using info from another of your posts, try something like this: <?php $ages = array('Sue'=>'30','Art'=>'40','John'=>'50','Mike'=>'60'); $genders = array('John'=>'M','Mike'=>'M','Sue'=>'F','Art'=>'M'); foreach ($ages AS $name =>$age) $people[$name]['age'] = $age; foreach ($genders AS $name =>$gender) $people[$name]['gender'] = $gender; ?> <pre><?php print_r($people) ?></pre> Code (markup): I hope this helps, Salsa _______