PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
It's ok if you're sure each word is separated by a single space. However, count() is more widely used, I think (functionality is the same as sizeof()).
Also as a general idea of how to find optimizations to things like this ( I know the function exists that does this for you but this applies to programming in general not just this function )
Look at what your code does, it splits on the space and then counts the elements, what this is basically doing is counting the number of spaces inside the string, so to optimize you would just count the number of spaces (instead of creating an array, then having the count function, etc.. which brings more overhead into the application)