3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $data = Array ( "Ron" => Array ( "subject1" => Array ( "test1" => 47, "test2" => 86, "total" => 133, "percentage" => 88.67, "status" => "Pass", "pass_count" => 8, "fail_count" => 0, "gross_total" => 963, "gross_percentage" => 80.25, ), "subject8" => Array ( "test1" => 48, "test2" => 86, "total" => 134, "percentage" => 89.33, "status" => "Pass", "pass_count" => 8, "fail_count" => 0, "gross_total" => 900, "gross_percentage" => 75.50, ), ), "John" => Array ( "subject1" => Array ( "test1" => 39, "test2" => 72, "total" => 111, "percentage" => 74, "status" => "Pass", "pass_count" => 8, "fail_count" => 0, "gross_total" => 963, "gross_percentage" => 80.25, ), "subject8" => Array ( "test1" => 39, "test2" => 75, "total" => 114, "percentage" => 76, "status" => "Pass", "pass_count" => 8, "fail_count" => 0, "gross_total" => 846, "gross_percentage" => 70.5, ), ), ); print_r($data); $table = table_cell($data); echo $table; function table_cell($data) { $return = "<table border='1'>"; foreach ($data as $key => $value) { $return .= "<tr><td>$key</td><td>"; if (is_array($value)) { $return .= table_cell($value); } else { $return .= $value; } $return .= "</td><tr>"; } $return .= "</tr></table>"; return($return); }
based on XWFGe
Output for 4.3.0 - 7.2.0
Array ( [Ron] => Array ( [subject1] => Array ( [test1] => 47 [test2] => 86 [total] => 133 [percentage] => 88.67 [status] => Pass [pass_count] => 8 [fail_count] => 0 [gross_total] => 963 [gross_percentage] => 80.25 ) [subject8] => Array ( [test1] => 48 [test2] => 86 [total] => 134 [percentage] => 89.33 [status] => Pass [pass_count] => 8 [fail_count] => 0 [gross_total] => 900 [gross_percentage] => 75.5 ) ) [John] => Array ( [subject1] => Array ( [test1] => 39 [test2] => 72 [total] => 111 [percentage] => 74 [status] => Pass [pass_count] => 8 [fail_count] => 0 [gross_total] => 963 [gross_percentage] => 80.25 ) [subject8] => Array ( [test1] => 39 [test2] => 75 [total] => 114 [percentage] => 76 [status] => Pass [pass_count] => 8 [fail_count] => 0 [gross_total] => 846 [gross_percentage] => 70.5 ) ) ) <table border='1'><tr><td>Ron</td><td><table border='1'><tr><td>subject1</td><td><table border='1'><tr><td>test1</td><td>47</td><tr><tr><td>test2</td><td>86</td><tr><tr><td>total</td><td>133</td><tr><tr><td>percentage</td><td>88.67</td><tr><tr><td>status</td><td>Pass</td><tr><tr><td>pass_count</td><td>8</td><tr><tr><td>fail_count</td><td>0</td><tr><tr><td>gross_total</td><td>963</td><tr><tr><td>gross_percentage</td><td>80.25</td><tr></tr></table></td><tr><tr><td>subject8</td><td><table border='1'><tr><td>test1</td><td>48</td><tr><tr><td>test2</td><td>86</td><tr><tr><td>total</td><td>134</td><tr><tr><td>percentage</td><td>89.33</td><tr><tr><td>status</td><td>Pass</td><tr><tr><td>pass_count</td><td>8</td><tr><tr><td>fail_count</td><td>0</td><tr><tr><td>gross_total</td><td>900</td><tr><tr><td>gross_percentage</td><td>75.5</td><tr></tr></table></td><tr></tr></table></td><tr><tr><td>John</td><td><table border='1'><tr><td>subject1</td><td><table border='1'><tr><td>test1</td><td>39</td><tr><tr><td>test2</td><td>72</td><tr><tr><td>total</td><td>111</td><tr><tr><td>percentage</td><td>74</td><tr><tr><td>status</td><td>Pass</td><tr><tr><td>pass_count</td><td>8</td><tr><tr><td>fail_count</td><td>0</td><tr><tr><td>gross_total</td><td>963</td><tr><tr><td>gross_percentage</td><td>80.25</td><tr></tr></table></td><tr><tr><td>subject8</td><td><table border='1'><tr><td>test1</td><td>39</td><tr><tr><td>test2</td><td>75</td><tr><tr><td>total</td><td>114</td><tr><tr><td>percentage</td><td>76</td><tr><tr><td>status</td><td>Pass</td><tr><tr><td>pass_count</td><td>8</td><tr><tr><td>fail_count</td><td>0</td><tr><tr><td>gross_total</td><td>846</td><tr><tr><td>gross_percentage</td><td>70.5</td><tr></tr></table></td><tr></tr></table></td><tr></tr></table>