- var_dump: documentation ( source)
- range: documentation ( source)
<?php
class test {
public static $callCounters = [];
public function call($index) {
if (!isset(self::$callCounters[$index])) {
self::$callCounters[$index] = 0;
}
++self::$callCounters[$index];
}
};
$x = new test();
$indexes = range('a','e');
foreach($indexes as $index) {
for($i = 0; $i <= 2; ++$i) {
$x->call($index);
}
}
var_dump(test::callCounters);