3v4l.org

run code in 300+ PHP versions simultaneously
<?php function str_reverse($string) { if (! is_string ( $string )) { exit ( 'not string' ); } $length = strlen ( $string ); $str_array = str_split ( $string ); $str_reverse = ''; for($i = $length - 1; $i >= 0; $i --) { $str_reverse .= $str_array [$i]; } echo $str_reverse; } $str = 'abcdef ss '; echo str_reverse ( $str );

preferences:
33.49 ms | 402 KiB | 5 Q