Php Check Array Size Javascript Function Definition