Question: I`m trying to do the next task:
I have a string, for ex. "Product with a very long name so that it goes on to more than one line". I want to make next customization: if a number of charackters in the string (without spaces) will be more than 22, cut it on the last word, and add "...".

Answer: 
```
<?php
  if(strlen($yourString) > 22)
    $rest = substr($yourString, 22,-1)."...";
  else
    $rest = $yourString;
  echo $rest;
?>

```

If you want that last word doesn't cut then,

```
<?php
$yourString = "bla blaaa bla blllla bla bla";
$out = "";
if(strlen($yourString) > 22) {
    while(strlen($yourString) > 22) {
        $pos = strrpos($yourString, " ");
        if($pos !== false && $pos <= 22) {
            $out = substr($yourString,0,$pos);
            break;
        } else {
            $yourString = substr($yourString,0,$pos);
            continue;
        }
    }
} else {
    $out = $yourString;
}
echo "Output String: ".$out;
?>

```
```
if(strlen($myString)>=22)
{
  $result = substr($myString, 0, 22)."...";
}
else
{
  $result = $myString;
}

```