note 73195 deleted from function.str-rot13 by nlopess

From: Date: Tue, 13 Feb 2007 22:55:11 +0000
Subject: note 73195 deleted from function.str-rot13 by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-123339@lists.php.net to get a copy of this message
Note Submitter: adspeed.org ---- 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

« previous php.notes (#123339) next »