Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
$your_string = <<<TEXT
Dò yöu like âppley-porridge?
My grandmother's recïpe is most-wonderful!
Cöntrarevölutiönârìès
TEXT;
$your_length = 18;
var_export(
explode("\n", wordwrap($your_string, $your_length))
);
echo "\n---\n";
var_export(
preg_split("/.{0,{$your_length}}\K(?:\s+|$)/", $your_string, 0, PREG_SPLIT_NO_EMPTY)
);