note 73195 added to function.str-rot13

From: Date: Mon, 12 Feb 2007 23:30:59 +0000
Subject: note 73195 added to function.str-rot13
Groups: php.notes 
Request: Send a blank email to php-notes+get-123296@lists.php.net to get a copy of this message
If you find str_rot13 is limited, this is a more customized string rotation function. It allows you to specify how many characters to shift (positive for moving forward, negative for moving backward) and also which characters to shift <?php /** rotate/shift a string */ function rotateString($pInput,$pRotateNum=0) { $vOutput = ''; $vStr = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890|'; $vLen = strlen($vStr); for ($i=0;$i<strlen($pInput);$i++) { $vIndex = strpos($vStr,$pInput{$i}); if ($vIndex===FALSE) { // non-encode chars, leave these alone $vOutput .= $pInput{$i}; } else { $vIndex = $vIndex+$pRotateNum; $vIndex = $vIndex>0?$vIndex%$vLen:($vLen+$vIndex)%$vLen; $vOutput .= $vStr{$vIndex}; } // fi } // rof //var_dump($vOutput); return $vOutput; } ?> Source: http://adspeed.org/2007/02/php-customize-strrot13-function.html ---- Server IP: 216.194.113.175 Probable Submitter: 71.202.106.187 ---- Manual Page -- http://www.php.net/manual/en/function.str-rot13.php Edit -- https://master.php.net/note/edit/73195 Del: integrated -- https://master.php.net/note/delete/73195/integrated Del: useless -- https://master.php.net/note/delete/73195/useless Del: bad code -- https://master.php.net/note/delete/73195/bad+code Del: spam -- https://master.php.net/note/delete/73195/spam Del: non-english -- https://master.php.net/note/delete/73195/non-english Del: in docs -- https://master.php.net/note/delete/73195/in+docs Del: other reasons-- https://master.php.net/note/delete/73195 Reject -- https://master.php.net/note/reject/73195 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#123296) next »