foreach ($array as $index => $value) {}
You have a two-dimentional array there. There's two levels of arrays,
and you're going to need foreach twice, once for each level. The first
level with have the store name as $index above and the store's price
list array as the $value. The second level foreach will take the store's
price list array and use the item as the $index and the price as the
$value.
Why don't you show the printout code you currently have? I have a
suspicion of what you're doing, but it's hard to tell without the code
(or a subset, basically I need to see how you have your foreachs setup.)
-Nick
On Sun, 2011-07-03 at 14:01 -0500, Byron Como wrote:
> <?php
>
>
> $foodprices =array('Albertsons'=>
>
> array('pizza'=>'$11.95','spinach'=>'.75c','tomatos'=>'3 for a
> dollar','anchovies'=>'$2.25'),
> 'Whole Foods'=>
>
> array('pizza'=>'$15.99','spinach'=>'$2.25','tomatos'=>'$1.95 /
> pound','anchovies'=>'$8.75'));
>
>
> foreach......
>
>
> ?>
>
> Desired output:
>
> Albertsons
> pizza $11.95
> spinach .75c
> tomatos 3 for a dollar
> anchovies $2.25
> Whole Foods
> pizza $15.99
> spinach $2.25
> tomatos $1.95 / pound
> anchovies $8.75
>
> The problem: I can't get the store name to print out, just the item and
> the price. The store names appear as 'array'.
>
> _______________________________________________
> General mailing list
> [email protected]
> http://brlug.net/mailman/listinfo/general_brlug.net
_______________________________________________
General mailing list
[email protected]
http://brlug.net/mailman/listinfo/general_brlug.net