PHP strings: is there a way to count spaces in front of strings?
===

I have some text and I explode()-ed it in an array. Each line of this text is one row.
I'm doing lots of operations on them, but that doesn't matter. The problem I'm having, is that whitespaces in front of each line are not shown when I print each line. 

But if I do 

    if(substr($array[$i], 0, 1)!=" ") { ...

 this seems to work. So I am adding spaces manually when printing out lines.
Any idea why this would happen? 

Anyhow, I would like to find a function (if there is one) that counts whitespaces infront of a string? Is there a combination of functions or something in PHP that I could use?

Thanks 