strrpos

  • To find the position of the last occurrence of asubstring within a string of characters, we can use Ruby’s String#rindex method.

    PHP

    print strrpos("hello world", "o");
    // => 7

    Ruby

    p "hello world".rindex("o").
    # => 7

    see also

strrev strstr

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.