How do I insert a string after every 50 words using php
<p>I have to insert a <code>&lt;br&gt;</code> tag after every 52 words so that it displays a line break otherwise the paragraph keeps going on and on increasing its width rather that the height. I fthere is any other, better way, please tell me. Thanks.
My code-</p>

<pre><code>&lt;?php
        $str = "Hello world. My name is Yash Mathur and I am a student. 
    I need help in this question as this is getting on my nerves, so I came to 
    stackoverflow.com 
    to seek for an answer. Please help me insert a line break after every 52 characters. 
    Thanks in advance!";
       $len = strlen($str);
       if($len &gt; 52){
        $str = substr($str, 0 , 52)."&lt;br&gt;";
        }
       echo $str;
       ?&gt;
</code></pre>

<p>I need to somehow put this in a loop to insert the <code>&lt;br&gt;</code> tag every 52 characters. </p>
