boiling down code<

windows

Guest
ok another stupid question by me.
is there another (less code intensive)way of putting this:

$array["name"] = trim($array["name"]);
$array["address"] = trim($array["address"]);
$array["address2"] = trim($array["address2"]);
$array["address3"] = trim($array["address3"]);
$array["city"] = trim($array["city"]);
$array["postcode"] = trim($array["postcode"]);
$array["tel"] = trim($array["tel"]);
$array["fax"] = trim($array["fax"]);
$array["email"] = trim($array["email"]);
$array["aims"] = trim($array["aims"]);
$array["activities"] = trim($array["activities"]);
$array["activity2"] = trim($array["activity2"]);
$array["activity3"] = trim($array["activity3"]);
$array["activity4"] = trim($array["activity4"]);
$array["opening_hours"] = trim($array["opening_hours"]);
$array["referrals"] = trim($array["referrals"]);


someone already suggested doing this:
foreach($array as $key => $val) {
$array[$key] = trim($val);
}
but being a complete novice at this i dont understand it. I dont understand where the name, address etc come into it.

could someone please explain this in real idiotspeak. The manual makes sweet FA sense to me too so i mean real idiotspeak here.Replace all that junk of code with the foreach loop. You seem to have the array values defined already because you do
$array["name"] = trim($array["name"]);
which menas that $array["name"] is already defined at that point.
 
Back
Top