This won't work if one of the arguments has spaces between quotes, which shouldn't be split. Can you instead use http://linux.die.net/man/3/wordexp? It should handle all the corner cases of command line processing. Also, that way you won't need the str_split function.