I'm having a few issues with the php explode function.
The string i want to explode is:
,.stl,.ppl
Currently, i'm using the explode function as such:
explode(',',',.stl,.ppl');
Unfortunately this is problematic, it returns three strings:
array(3) { [0]=> string(0) "" [1]=> string(4) ".stl" [2]=> string(4) ".ppl" }
Why is the first string blank?
The obvious solution is to skip the first element of the array, however, why do i need to do this?
Shouldn't the explode()
function automatically remove this blank array, or not even generate it at all?
,
in the string, so technically, you have three items, the first being blank, soexpldoe
just do what it's your expectation wrong. You might want to usetrim
on the string to trim leading/trailing,
to address this issue – Hoenack