You are here: Re: associative array in associative array « PHP Programming Language « IT news, forums, messages
Re: associative array in associative array

Posted by Michael Cooney on 01/17/07 22:26

In your nested foreach, you're trying to loop over the key as opposed
to the nested array.

Change:
foreach ($k as $k2 => $v2) {
to:
foreach ($v as $k2 => $v2) {

Antoine Merieux wrote:
> Hi,
> I'm trying to use associative array in another associative array
>
> to feed it's ok
> to retrieve, something's wrong
> can you help me
> thank you
>
> <?php
> session_start();
> $tabItems = array(49, 59, 69, 79);
> $tabExercice = array(
> '1' => $tabItems,
> '45' => $tabItems);
>
> $tab = array(
> '487' => $tabExercice,
> '45' => $tabExercice,
> '23' => $tabExercice);
>
> $_SESSION['caddy'] = $tab;
>
> //print_r($tab);
>
> // Let see what is it
> foreach ($tab as $k => $v) {
> // the key is id_focus
> echo "Liste des exercices pour le focus".$k;
> foreach ($k as $k2 => $v2) {
> // the key is id_exo
> echo "<br>id_exo =".$k2;
> echo "<br>liste des items";
> for ($i=0; $i < count($v2); $i++)
> {
> echo $v2[$i]." ";
> }
> }
> }
>
> ?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация