if (length(substr($var, index($var, ' '), rindex($var, ' ')+1)) == length($var) { Dosomething(); }