Portrety Uliczne Nieznajomych - zobacz wyjątkową galerię portretów z warszawskich ulic
ZALOGUJ SIĘ
login:
hasło:
przypomnij hasło
załóż konto użytkownika
(i zobacz kilka porad gratis)
   
WYSZUKIWARKA I DZIAŁY
całe porady  tytuły
zaznacz działy do przeszukania
(brak wyboru = wszystkie działy)
PHP
MySQL >
PostgreSQL
SQLite
Perl
Java
XML
XSLT
XPath
WML
SVG
RegExp
Wyszukiwarki
Ochrona
VBScript
Google Plus
XHTML/CSS
JavaScript
Grafika
Flash
Photoshop
Windows
Linux
Bash
Apache
Procmail
E-biznes
Explorer
Opera
Firefox
Inne porady
   
KURSY, DOKUMENTACJE
Własne:
XHTML/CSS
JavaScript
ActionScript
WML, RSS, SSI
Pozostałe:
PHP
MySQL
Java API
więcej...
   
użytkowników online: 42
W CZYM MOGĘ POMÓC?


   
OPINIE UŻYTKOWNIKÓW
Mimo, że strony WWW tworzymy już 5 lat zawsze znajdziemy coś ciekawego. Świadczy o tym chociażby nasza aktówka, w której znajduje się kilkadziesiąt porad, z których często korzystamy. Otwarta forma poradnika, czyli możliwość podrzucania tematów oraz wspólny ich rozwój, to nieoceniona pomoc. Uważam, ze abonament roczny jest niewspółmiernie niski do jakości zaprezentowanych materiałów.

Marek Kończal
Internetix.pl

   
GALERIA FOTOGRAFII
   
PODRĘCZNIK PHP 5.x, 4.x, 3.x - częściowo spolszczony / źródło: www.php.net

[Spis] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [X] [W] [Z]

str_rot13

(PHP 4 >= 4.2.0, PHP 5)

str_rot13 -- Perform the rot13 transform on a string

Description

string str_rot13 ( string str )

This function performs the ROT13 encoding on the str argument and returns the resulting string. The ROT13 encoding simply shifts every letter by 13 places in the alphabet while leaving non-alpha characters untouched. Encoding and decoding are done by the same function, passing an encoded string as argument will return the original version.

Przykład 1. str_rot13() example

<?php

echo str_rot13('PHP 4.3.0'); // CUC 4.3.0

?>

Notatka: The behaviour of this function was buggy until PHP 4.3.0. Before this, the str was also modified, as if passed by reference.




User Contributed Notes

none at none dot com
12-Nov-2005 11:18

Own function rot 13:

function rot13($txt)
{
   $char = range('a', 'z');
   $flip = array_flip($char);
  
   for( $i = 0; $i < strlen($txt); $i++ )
   {
     if ( !in_array($txt[$i], $char) )
     {
       $out .= $txt[$i];
     }
     else
     {
       $tmp = $flip[$txt[$i]];
      
       if ( $tmp <= 12 )
       $tmp = $tmp + 13;
       else
       $tmp = $tmp - 13;
       $out .= $char[$tmp];
     }
   }
   return $out;
}


Anonymous
11-Dec-2004 02:26

There is a workaround for the reference problem:

instead of:

<?php
$rot13
= str_rot13($str);
?>

do

<?php
$rot13
= str_rot13($str . "");
?>

In that case str_rot13() won't treat the value as a variable, but more as "hard-coded" (and won't pass the variable for reference)


joh at n dot liesen dot se
26-Nov-2004 05:35

It's also possible to rot13 a string without using a lookup table.

<?php
function rot13($s)
{
  
$rot13  = "";
  
   for (
$i = 0; $i < strlen($s); ++$i)
   {
    
$char = ord($s{$i});
    
$cap = $char & 32;
    
    
$char &= ~$cap;
    
$char = (($char >= ord('A')) && ($char <= ord('z'))) ? (($char - ord('A') + 13) % 26 + ord('A')) : $char;
    
$char |= $cap;
    
    
$rot13 .= chr($char);
   }
  
   return
$rot13;
}
?>


kristof_polleunis at yahoo dot com
15-Jul-2004 05:05

For versions of php <= 4.2.0 you can use:

function rot13($str){
if (!function_exists('str_rot13')) {
   $from = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
   $to  = 'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM';
   $rot13str = strtr($str, $from, $to);
}else{
   $rot13str = str_rot13($str); 
}
return $rot13str;
}


 

 
  © 1996-2012 & Reporter.plmiejscao serwisieabonamentwarunki korzystaniaRSSkontakt