|
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]
|