I`m using tinymce as text editor on my website.
Sometimes when I wrote some text and save it the html code is a “broken”.
It seems there are some unclosed html tags which broke the css layout. This is what is found as a solution http://www.php.net/manual/en/tidy.examples.php
Is there some other technique (php) to autocomplete unclosed tags ?
Tidy is the way to go for you. Any custom solution e.g. using regular expressions would be worse than what tidy was designed for.
But the real problem, that TinyMCE is creating unclosed tags sounds like there is some problem with your TinyMCE installation – are you sure you are using the most current version (3.3.9.2)? It should not output unclosed tags, only if you manipulate the HTML source manually.