• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Displaying nested array help

#1
[eluser]whiteae[/eluser]
So I have an array I want to display as a table. I know how to do this through a foreach, but I keep getting errors saying the index is wrong when I try to display the last array items in the APQIDSTRING array. I want to display these as a bulleted in their own cell list like so..
<td>
() Trim Package - XLT
() Trim Package - Sport
() so on and so forth..
</td>

Here is the array
Code:
Array
(
    [0] => Array
        (
            [YEAR] => 1994
            [MAKE] => FORD
            [MODELIND] => EXPLORER
            [SUBMODEL] =>
            [ENGTYPE] => V6
            [LITER] => 4.0
            [FUEL] => GAS
            [FUELDEL] => FI
            [FUELCONFIG] => SFI
            [ASP] => N
            [ENGVIN] => X
            [ENGDESG] =>
            [VQIDSTRING] =>
            [APQIDSTRING] =>
            [FNIDSTRING] =>
        )

    [1] => Array
        (
            [YEAR] => 1993
            [MAKE] => FORD
            [MODELIND] => EXPLORER
            [SUBMODEL] =>
            [ENGTYPE] => V6
            [LITER] => 4.0
            [FUEL] => GAS
            [FUELDEL] => FI
            [FUELCONFIG] => SFI
            [ASP] => N
            [ENGVIN] => X
            [ENGDESG] =>
            [VQIDSTRING] =>
            [APQIDSTRING] =>
            [FNIDSTRING] =>
        )

    [2] => Array
        (
            [YEAR] => 1992
            [MAKE] => FORD
            [MODELIND] => RANGER
            [SUBMODEL] =>
            [ENGTYPE] => L4
            [LITER] => 2.3
            [FUEL] => GAS
            [FUELDEL] => FI
            [FUELCONFIG] => MFI
            [ASP] => N
            [ENGVIN] => A
            [ENGDESG] =>
            [VQIDSTRING] =>
            [APQIDSTRING] => Array
                (
                    [0] => Array
                        (
                            [APQCatDescr] => Trim Package
                            [APQDescr] => XLT
                        )

                    [1] => Array
                        (
                            [APQCatDescr] => Trim Package
                            [APQDescr] => Sport
                        )

                    [2] => Array
                        (
                            [APQCatDescr] => Trim Package
                            [APQDescr] => STX
                        )

                )

            [FNIDSTRING] =>
        )

#2
[eluser]michalsn[/eluser]
This is just a sample, and seems to work ok.
Code:
foreach ($arr as $a)
{
    echo $a['YEAR'].' ';
    if (is_array($a['APQIDSTRING']))
    {
        foreach ($a['APQIDSTRING'] as $s)
        {
            echo $s['APQCatDescr'].' - '.$s['APQDescr'].'; ';
        }
    }
    echo '<br />';
}

#3
[eluser]whiteae[/eluser]
Thank you. I was getting confused by all of the nests haha and getting errors when I thought it should've been right.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.