I need to search and replace in a string, I want to replace the last occurrence of a string.
Here's my working code (which just does a normal search/replace):
PREG_REPLACE("/(\b{$abbr}\b)/i", "$long" , $street_address)
Example of expected results:
- $street_address = "123 St Martin St"
- $abbr = "St"
- $long = "Street"
- return = "123 St Martin Street"
I want only the last occurrence of St replaced with Street.