How to get part of string without using substr() function

  php, regex, string, substr

I have a string like this:

$str = "65moneyback";

Now I need to get moneyback from this string and store in a new variable.

So basically I can easily use substr() function to do this, but the problem is, the number at the beginning can be anything else such as 135moneyback or 9moneyback and etc.

Therefore I don’t know when the moneyback starts from exactly and what to enter as index for substr() function.

But the moneyback part stays the same always.

So the question is, how to get moneyback from these kinds of string variables properly?

Source: Ask PHP

LEAVE A COMMENT