php trim string if longer than code example Example: php trim string if longer than substr($str,0,50);