Re: rot13?

From: Date: Mon, 12 Jun 2000 07:04:18 +0000
Subject: Re: rot13?
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-21083@lists.php.net to get a copy of this message
Actually, you can do this with a one-liner: strtr($text,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ","nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM"); Ok, so it is a rather long line... On Mon, 12 Jun 2000, Theodore Baschak wrote: > Theres no rot13 code in php that I know of.. but its raelly easy to write.. > maybe someone could re-write this in C and put it in sometime? > > <?php > function rot13($text) { > for ($i=0,$len=strlen($text);$i<$len;$i++) { > if > (strstr('abcdefghijklmnopqrstuvwxzyABCDEFGHIJKLMNOPQRSTUVWXYZ',$text[$i])) { > $text[$i] = chr(ord($text[$i]) + > ((strtoupper($text[$i]) > 'M') ? -13 : 13)); > } > } > return $text; > } > ?> > > Theodore > > >

« previous php.dev (#21083) next »