<?php

// Compatibility function
// http://www.pgregg.com/projects/php/code/str_rotN.php
// Author: Paul Gregg

show_source(__FILE__);

// Generic rotate by any number
function rot_n($str$num=13) {
  return 
preg_replace('/([a-z])/ei''chr(((ord(\'$0\')-(ord(\'$0\')>96?97:65)+$num)%26)+(ord(\'$0\')>96?97:65))'$str);
}

// Standard rot13 function
if (!function_exists('str_rot13')) {
  Function 
str_rot13($str) {
    return 
preg_replace('/([a-z])/ei''chr(((ord(\'$0\')-(ord(\'$0\')>96?97:65)+13)%26)+(ord(\'$0\')>96?97:65))'$str);
  }
}


$str "Hello World.\n";

echo 
'<hr>'$str;
echo 
'<br>'str_rot13($str);
echo 
'<br>'rot_n($str);
?>

Hello World.
Uryyb Jbeyq.
Uryyb Jbeyq.