NYCPHP Meetup

NYPHP.org

[nycphp-talk] walking through a multi-dimensional array

Michael Southwell southwell at dneba.com
Fri Jul 25 16:20:20 EDT 2003


The following code successfully walks through a 3-element array:

for ($i=1;$i<=$articlecount;++$i){
   echo "<input type=\"radio\" name=\"which\" 
value=\"".$articles[$i][0]."\" 
/>".$articles[$i][1].":  ".$articles[$i][2]."<br />";
}

I was also trying to do it with while-list-each but this doesn't work:
while (list($key,$value)=each($articles)){
   while (list($key2,$url,$date,$title)=each($value)){
     echo "<input type=\"radio\" name=\"which\" value=\"".$url."\" 
/>".$date.":  ".$title."<br />";
   }
}

At this point I think the for-loop is best but for the sake of general 
knowledge, how do I do it the other way?  TIA.

Michael G. Southwell =================================
DNEBA Enterprises
81 South Road
Bloomingdale, NJ 07403-1419
973/492-7873 (voice and fax)
southwell at dneba.com
http://www.dneba.com
======================================================





More information about the talk mailing list