$out = strlen($in) > 50 ? substr($in,0,50)."..." : $in;
if(strlen(trim($string)) > 0){ // $string has at least one non-space character }