<?php
$operations = array('+', '-', '*', '%'); foreach ($operations as $op) {
}
function mathOperation($a, $b, $operation) {
global $functions;
// return call_user_func($functions[$operation], $a, $b);
return $functions[$operation]($a, $b);
}
header('Content-Type: text/plain'); foreach (array('+', '-', '*', '%') as $operation) { echo mathOperation(5, 3, $operation) . "\n";
}
PD9waHAKJG9wZXJhdGlvbnMgPSBhcnJheSgnKycsICctJywgJyonLCAnJScpOwokZnVuY3Rpb25zID0gYXJyYXkoKTsKZm9yZWFjaCAoJG9wZXJhdGlvbnMgYXMgJG9wKSB7CiAgICAkZnVuY3Rpb25zWyRvcF0gPSBjcmVhdGVfZnVuY3Rpb24oJyRhLCAkYicsICdyZXR1cm4gJGEgJyAuICRvcCAuICcgJGI7Jyk7Cn0KZnVuY3Rpb24gbWF0aE9wZXJhdGlvbigkYSwgJGIsICRvcGVyYXRpb24pIHsKICAgIGdsb2JhbCAkZnVuY3Rpb25zOwogICAgLy8gcmV0dXJuIGNhbGxfdXNlcl9mdW5jKCRmdW5jdGlvbnNbJG9wZXJhdGlvbl0sICRhLCAkYik7CiAgICByZXR1cm4gJGZ1bmN0aW9uc1skb3BlcmF0aW9uXSgkYSwgJGIpOwp9CgpoZWFkZXIoJ0NvbnRlbnQtVHlwZTogdGV4dC9wbGFpbicpOwpmb3JlYWNoIChhcnJheSgnKycsICctJywgJyonLCAnJScpIGFzICRvcGVyYXRpb24pIHsKICAgIGVjaG8gbWF0aE9wZXJhdGlvbig1LCAzLCAkb3BlcmF0aW9uKSAuICJcbiI7Cn0=