I\'m using a map in php like so:
function func($v) { return $v * 2; } $values = array(4, 6, 3); $mapped = array_map(func, $values); var_dump($mapped);
You can create your own map function using foreach:
foreach
$val) { $result[$key] = $callback($key, $val); } return $result; } $values = array(4, 6, 3); $mapped = foreachMap('myCallback', $values); var_dump($mapped);
try: https://3v4l.org/pmFlB