PHP's explode function returns an array of strings split on some provided substring. It will return empty strings like this:
var_dump(explode('/', '1/2//3/'));
array(5) {
[0]=>
string(1) "1"
[1]=>
string(1) "2"
[2]=>
string(0) ""
[3]=>
string(1) "3"
[4]=>
string(0) ""
}
Is there some different function or option or anything that would return everything except the empty strings?
var_dump(different_explode('/', '1/2//3/'));
array(3) {
[0]=>
string(1) "1"
[1]=>
string(1) "2"
[2]=>
string(1) "3"
}
question from:
https://stackoverflow.com/questions/64570/explode-that-doesnt-return-empty-strings 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…