Re: array block
| From: | John Schulz | Date: | Fri, 30 Jan 2004 23:40:58 +0000 |
| Subject: | Re: array block | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-176416@lists.php.net to get a copy of this message | ||
Brian V Bonini wrote:
I'm having array block, trying to format the data in a two dimensional associative array.
foreach($menu as $k => $v) { etc.. need to end up with <a href=url title=title>link(x)</a>Since it's two-dimensional, the $v you're getting is actually an array. So you'll have to iterate through the outer array, $menu, and then do it again for each inner array. As was mentioned before/elsewhere, a for would be more efficient than a foreach unless you actually need a specific key or value. So something like $count = sizeof($menu); for ( i=0; i<$count; i++) { foreach( array_shift($menu) as $k => $v ) { //ect. } } It's been a long day; please, someone verify this... :)