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.
PHP

Avatar of undefined
Last Comment
Cornelia Yoder
ASKER CERTIFIED SOLUTION
Avatar of jimkar
jimkar

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Sekurity863
Sekurity863
Flag of United States of America image

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
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

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
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.
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo