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.

 

Link to comment
Share on other sites

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

Edited by lilmer
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.