Your code is too optimistic. You do not factor that $x may not Split() out to 4 elements.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.