note 75383 deleted from function.str-rot13 by nlopess

From: Date: Sun, 27 May 2007 19:02:40 +0000
Subject: note 75383 deleted from function.str-rot13 by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-126967@lists.php.net to get a copy of this message
Note Submitter: Paul Gregg, Qube@EfNet #PHP ---- http://www.pgregg.com/projects/php/code/rot_n.php Compat function if you have older PHP: 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); } } Or if you want to be able to rotate by some digit other than 13: 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); }

« previous php.notes (#126967) next »