Friday 15 January 2010

Spliting string based on length from end in PHP -


I want to split a string from the back. Like:

  $ mystring = "This is my string"; $ Mysecondstring = "histimistration";   

I want to divide the last 6 characters from the above stars, here it is "string". How can I do PHP? By using str_split , I can divide by the front, but I need it from the end.

Thanks in advance.

Use

edit

  $ snippet = substr ($ mystring, 0), -6);    

No comments:

Post a Comment