Avatar of hankknight
hankknightFlag for Canada asked on

Find position of last occurrence of string

strpos finds the position of the first occurrence of a string.  I want to find the position of the LAST occurrence of a string.

Avatar of undefined
Last Comment
Cornelia Yoder

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

mb_strripos  Finds position of last occurrence of a string within another, case insensitive

mb_strrpos  Find position of last occurrence of a string in a string, case sensitive
Ray Paseur

Hi, Hankknight.  Depending on what you want to do with the string you might explode it into an array.  If you do that you can use end() to find the last element of the exploded data. ~Ray
Cornelia Yoder

Note that strrpos() does not work on anything except a SINGLE character in php 4, so be sure you have php 5 before you try to use this.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck