Why not just reuse the $map variable and do something like:
$map = (array) $map;