Search code examples
phpstringsplit

Split a string only on the first of its multiple delimiters to produce a 2-element array


How can I isolate the numbers and words in a string?

So I have something like this:

11111111-test-title

I want to have:

11111111

...in one string and:

test-title

...in another.


Solution

  • $parts = explode('-', $string, 2);