$keys = array_keys($arr);
$head = "<tr><th>year</th>".implode("", array_map(function($n) {
return "<th>$n</th>";
}, $keys))."</tr>";
$rows = implode("", array_map(function($key) use($arr) {
return "<tr><td>$key</td>".implode("", array_map(function($n) use($key) {
return "<td>$n[$key]</td>";
}, $arr))."</tr>";
}, array_keys($arr[$keys[0]])));
echo "<table>$head$rows</table>";
<?php
class AAA {
private $a = '777';
function __toString() {
return \sprintf("%s\n", $this->a);
}
}
$a = new AAA;
echo $a;
$b = new ReflectionClass(AAA::class);
$property = $b->getProperty('a');
$property->setAccessible(true);
$property->setValue($a, 999);
echo $a;
as@avs:~$ php7.1 /tmp/testReflection.php
777
999