$toOutput = reverse $temp[0]; $toOutput .= $x; $output = reverse $toOutput;