Jump to content

foreach Loop Variables?


h3110w0r1d

Recommended Posts

I guess I'll rephrase since my wording wasn't very clear. Why don't

 

echo "<p>\n";
if (!empty($locations) && is_array($locations)) {
  foreach ($locations as $field => $val) {
  if ($field == "City") {
    	echo $field  . ' : ' . $val . "<br />\n";
        $val = $cityvar;
	}
  if ($field == "ZipPostalCode") {
    	echo $field . ' : ' . $val . "<br />\n";
        $val = $zipvar;
	}
  if ($field == "CountryName") {
    	echo $field . ' : ' . $val . "<br />\n";
        $val = $countryvar;
	}
  }
}
echo "</p>\n";

Link to comment
https://forums.phpfreaks.com/topic/226820-foreach-loop-variables/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.