[EMAIL PROTECTED] wrote:

Hello,

If I have an associative array like:

$myFriendsAges['Tom']=25;
$myFriendsAges['Bill']=35;
$myFriendsAges['Al']=45;
$myFriendsAges['Mark']=55;

Is there a way to index name into a string. I would like to be able to echo something like:

My friend Bill is 35 years of age.

Is there a way to do this?

No sure what you mean... but it is possible this way:

<?php
foreach($myFriendsAges as $name=>$age) {
  echo "My friend ".$name." is ".$age." years of age.<br>\n";
}
?>

--
Johan Holst Nielsen
Freelance PHP Developer
http://phpgeek.dk

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to