- var_dump: documentation ( source)
- range: documentation ( source)
- rand: documentation ( source)
<?php
$x = new class() {
public $callCounters = [];
public function call($index) {
$this->callCounters[$index] ?? 0;
++$this->callCounters[$index];
}
};
$indexes = range('a','e');
foreach($indexes as $index) {
$r = rand(1,4);
for($i = 0; $i <= $r; ++$i) {
$x->call($index);
}
}
var_dump($x->callCounters);