<? $str = " 0"; function str_rev($str) { $i = 0; while(true){ if (!isset($str[$i])) { break; } $i++; } $rev = ""; for($j = $i - 1;$j >= 0; $j-- ){ $rev .= $str[$j]; } return $rev; } echo $str; echo str_rev($str);