Split string using 2 criterias in PHP
===

I am using this

    $lines = explode(PHP_EOL, trim($text));

to split $text into an array of lines so i can display like this:

    foreach ($lines as $line) {
     echo $line;
    }

but now i want to test the lenght of each $line and if lenght is over 50 chars i want to split each line in multiple of 50 chars.

How can i do this and keep all lines in the $lines array ?

I need a way to test each line or explode it using explode( wordwrap($line), 50 ); and then re-build the $lines array so i can cycle all lines again.

As I am not a coder I do not know how to insert new lines in the array if one line must be split in several pieces of 50 chars.

Hope you understand my question.
Thanks.