ord

  • We can find the ASCII value of a character in Ruby using the String#[] method. We use this method in Ruby to specify the index of the character we need.

    PHP

    $result = ord("t");
    var_export($result);
    // => 116

    Ruby

    p "t"[0]
    # => 116

    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.