I'm looking for the quickest approach to splitting a string into its leading spaces and the rest of it?
····sth
should become array("····", "sth")
and ·sth·
- array("·", "sth·")
* ·
= space
I'm looking for the quickest approach to splitting a string into its leading spaces and the rest of it?
····sth
should become array("····", "sth")
and ·sth·
- array("·", "sth·")
* ·
= space
$result = preg_split('/^(\s*)/', ' test ', -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
outputs
array(2) {
[0]=>
string(2) " "
[1]=>
string(5) "test "
}