- array_walk: documentation ( source)
<?php
function event($n, $h = null) { static $e = []; return $h ? $e[$n][] = $h : (isset($e[$n]) ? array_walk($e[$n], function($e) {$e();}) : 0); }
event('hello', function () { echo 'hello!'; });
echo event('hello') ? 'true!' : 'false!';
echo event('world') ? 'true!' : 'false!';