Robert John Concepcion
Robert John Concepcion

Reputation: 237

Auto line break after 5 characters

Guys i just wanna ask if there's a possibility: for example $currenttext = "someexamplepls"; if you would like to show or print it just use print "$currenttext"; then the prepared output look like this someexamplepls. My question is if i would like to print it like this:

somee
xampl
epls

in every 5 character there is automatic newline what should I do?

Upvotes: 2

Views: 5100

Answers (1)

ThiefMaster
ThiefMaster

Reputation: 318518

Use wordwrap():

echo wordwrap($str, 5, "\n", true);

In case you want HTML linebreaks use <br> instead of \n.

Upvotes: 10

Related Questions