str_rot13

  • There is no native rot13 method in Ruby, but we can easily get the same results using String#tr.

    PHP

    $result = str_rot13('Hello world');
    var_export($result);
    // => 'Uryyb jbeyq'

    Ruby

    p "Hello world".tr("A-Za-z", "N-ZA-Mn-za-m")
    # => "Uryyb jbeyq"

    see also

Looking for Rails or PHP web application development, integration, and training?

Rails for PHP is brought to you by Maintainable Software. Get custom web applications and personalized training from the authors of the book and website.