I have a string, and I must print it in a div. 

The width of the div is limited, so if many characters are close the string will exit from the div. 

Just think to a `width:30px` div and a string such as `hellomynameismarcoandilikemadewebapplicationinmyfreetimes`.

So I need a sort of function on php that cut recursively the string; I mean, cut the string and add somethings like `<br/>`. 

Another problem here is that my string is printed through `htmlentities($string, ENT_QUOTES, "UTF-8");` , so the `<br/>` will fail.

How can I do it on PHP?

**EDIT** My Final Solution

```
function printMyStrings($str, $width) {
    return ereg_replace("&lt;br/&gt;","<br/>", htmlentities(wordwrap($str, $width, "<br/>", true), ENT_QUOTES, "UTF-8"));
}

```