Typecasting $output before imploding