0

I have a variable that I am handling in PHP and need to delete everything in it after a (known) match of characters, the length before the match and after vary in size. I'm not sure how to do this, for example:

$variable = "1234356ABCtreecar"

The next content of $variable could be:

$variable = "654321123456ABCcartreehouse"

The ABC part would always be present in the content of the variable, which varies in size dynamically, I just need to 'keep' everything before ABC in the variable and disregard everything after, so to end with the content of $variable in the two above examples as:

$variable = "123456"

and

$variable = "654321123456"

Can anyone help with this please?

omega1
  • 1,031
  • 4
  • 21
  • 41

0 Answers0