Maybe I'm just stupid or something, but this function for php has always just escaped me and I've always just found other ways to do things. Now I'm up against a need that I think is going to require it. I've tried searching in about every way I can think of, but "each" returns 10,822 results and none of them have anything to do with the php function but are "...and each row in the database" or such. "For each" gives the same results because it says that its ignoring the "for." Other searches provide illustrations of using it with "list" to print out the the pairs, but the longer I look at them the less sense thay make to me. How does simply iterating a list help? There's a "as" in most of the samples and I'm not clear on what role it plays since it isn't mentioned at all. I've spent several hours on Google and on several boards doing searches and I'm nowhere.
Can someone point me in the direction from having an array that looks something like:
Code: Select all
array(31=>"foo",46=>"bash",51=>"sleep",88="etc")
To printing a series of statements like:
Code: Select all
echo "<option value=",?,"> ",?," </option>"
Which will wind up to the browser as:
Code: Select all
<option value=31> foo </option>