title: Add wordwrap to decoded json text
body: <p>I am using a simple script on my PHP webpage to decode and output JSON as text. However, what ever I try I can't get it to <code>wordwrap</code> the output.</p>
  
  <pre><code>$file = file_get_contents('sample.txt');
  $out = (json_decode($file));
  echo $out-&gt;mainText;
  </code></pre>
  
  <p>How can I get this script to <code>wordwrap</code> at 600 characters without chopping words in half?</p>
  
  <p>If possible, can you show me the whole script please as I am slowly learning.</p>
  
  <p>Thanks</p>