I need some help, is it possible to explode like this?
I have a string 45-test-sample
, is it possible to have
["45", "test-sample"]
How can it be done?
print_r(explode('-', $string, 2)); // take some help from the limit parameter
If limit is set and positive, the returned array will contain a maximum of limit elements with the last element containing the rest of string.
Output:
Array
(
[0] => 45
[1] => test-sample
)