Fri, 17 May 2024


How to wrap a string to a given number of characters?

By: Peter, NetArt Media
Sat, 6 March 2021

For this purpose you may use the wordwrap function which is available from PHP 4.0.2

<?php

$myString="long teeeeeeeext";

echo (wordwrap( $myString, 6 ));

?>

will display:

long
teeeee
eeext


Category: PHP Examples
Share this post:



See All Scripts






Subscribe for our newsletter

Receive the latest blog posts direct in your mailbox