Search code examples
phpstringsubstrstrposchars

How to select all characters to the right of a specific character in a string - PHP


I spent a long time trying to figure this out! How do I select all the characters to the right of a specific character in a string when I don't know how many characters there will be?


Solution

  • You can also do:

    $str = 'some_long_string';
    echo explode( '_', $str, 2)[1]; // long_string