How to use regex to extract string

Hi , can I ask help how can I extract the string,

I have this string paths and I’m looping on it, and I want to cut this string “/save/manage”

“/save/manage/01/01”
“/save/manage/02”
“/save/manage/06/08”

so that I can get this string
01/01
02
06/08

Thank you in advance

what is “this string”? the last 5 characters? substr(). The forth slash? strpos() with substr(). Two characters before and after the last slash? Same as before. Or explode().

Do you mean substr($string, -5);
That will get the last 5 characters from a string, in this case 01/01

Nope, because when my loop runs the string sometimes would look something like this “/save/manage/02” , so I need to cut the “/save/manage/” so that I can output 02

So the “/save/manage/” part of the string is consistent always?
That could be done with a simple str_replace() or substr() again, since the length (of the part to remove) is the same.

1 Like

How EXACTLY are they stored? In a database?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.