Add wordwrap to decoded json text

Posted by Gary on Stack Overflow See other posts from Stack Overflow or by Gary
Published on 2010-05-30T18:53:03Z Indexed on 2010/05/30 19:02 UTC
Read the original article Hit count: 324

Filed under:
|
|

Hi, 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 wordwrap the output.

$file = file_get_contents('sample.txt');
$out = (json_decode($file));
echo $out->mainText;

How can I get this script to wordwrap at 600 characters without chopping words in half?

If possible, can you show me the whole script please as I am slowly learning.

Thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about JSON