note 75382 added to function.str-rot13

From: Date: Fri, 25 May 2007 23:30:38 +0000
Subject: note 75382 added to function.str-rot13
Groups: php.notes 
Request: Send a blank email to php-notes+get-126931@lists.php.net to get a copy of this message
Perhaps someone will find this useful ;) <? function rotN($s, $n){ $s2 = ""; for($i = 0; $i < strlen($s); $i++){ $char2 = $char = ord($s{$i}); $cap = $char & 32; $char &= ~ $cap; $char = $char > 64 && $char < 123 ? (($char - 65 + $n) % 26 + 65) : $char; $char |= $cap; if($char < 65 && $char2 > 64 || ($char > 90 && $char < 97 && ($char2 < 91 || $char2 > 96))) $char += 26; else if($char > 122 && $char2 < 123) $char -= 52; if(strtoupper(chr($char2)) === chr($char2)) $char = strtoupper(chr($char)); else $char = strtolower(chr($char)); $s2 .= $char; } return $s2; } ?> It takes any string, $s, and any ROT value, $n. Just like str_rot13, it's both an encoder and decoder. To decode an encoded string, just pass -$n instead of $n. ---- Server IP: 66.207.199.35 Probable Submitter: 70.66.98.187 ---- Manual Page -- http://www.php.net/manual/en/function.str-rot13.php Edit -- https://master.php.net/note/edit/75382 Del: integrated -- https://master.php.net/note/delete/75382/integrated Del: useless -- https://master.php.net/note/delete/75382/useless Del: bad code -- https://master.php.net/note/delete/75382/bad+code Del: spam -- https://master.php.net/note/delete/75382/spam Del: non-english -- https://master.php.net/note/delete/75382/non-english Del: in docs -- https://master.php.net/note/delete/75382/in+docs Del: other reasons-- https://master.php.net/note/delete/75382 Reject -- https://master.php.net/note/reject/75382 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#126931) next »