Jump to content

Count sub array inside an array and post


lilmer

Recommended Posts

I've been playing for this and I really can't figure how to count the sub array and post a value:

 

Array
(
    [1] => Array
        (
            [A] => Hello
            [b] => 
            [C] => Hello
            [D] => 
        )

    [2] => Array
        (
            [A] => 
            [b] => world!
            [C] => 
            [D] => world!
        )

    [3] => Array
        (
            [A] => 
            [b] => 
            [C] => 
            [D] => 
        )

    [4] => Array
        (
            [A] => Miscellaneous
            [b] => 
            [C] => 
            [D] => 
        )

    [5] => Array
        (
            [A] => List
            [b] => bump
            [C] => 
            [D] => 
        )

)

 

So what I want to happen is:

 

<table>
<tbody>
 <tr>
    <td>Hello</td><td>B</td><td>Hello</td><td>D</td>
</tr>
 <tr>
    <td></td><td>world!</td><td></td><td>world!</td>
</tr>
 <tr>
    <td>A</td><td>B</td><td>C</td><td>D</td>
</tr>
 <tr>
    <td>A</td><td>B</td><td>C</td><td>D</td>
</tr>
 <tr>
    <td>A</td><td>B</td><td>C</td><td>D</td>
</tr>
</tbody>
</table>

 

 

I already count the main array, but I can't get the sub array and post them on a table data w/ each specific value.

 

I get it again.

 

$count = count($sheetData);
        
   echo "<table><tbody>";
        
   foreach($sheetData as $a => $k){
           
       echo "<tr>";
           
       $co = count($k);

       foreach ($k as $j => $value) {
       
         echo "<td>$value</td>";
            
       }
          
           echo "</tr>";
       }
        echo "<tbody></table>";

 

Jess rate $100/hour

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.