Search code examples
phpstringstrip

php remove characters from beginning to a selected character


I want to know is there is anything available in PHP to remove 437800__ From 437800__611.

Original: 437800__611

What i want to end up with: 611

Basically need to start from the beginning of the string, and stop just after __ to keep 611.


Solution

  • Try something like substr($str, strpos($str, '__') + 2). This will find the first occurrence of '__' (two consecutive underscores) and remove everything before the '__' including the underscores themselves.