PHP 8.5.0 Alpha 2 available for testing

Voting

: max(seven, three)?
(Example: nine)

The Note You're Voting On

neil at no-spam-ents24 dot com
24 years ago
The code posted above by Joerg Krause only works for a string which ends with one of the delimiters. A possible fix is:

<?php
$text
= "What?No delimiters,shit happens here.this solves all problems.";
preg_match_all("/(\w+[,. ?])+/U", $text, $words);
preg_match("/(\w+)$/", $text, $lastword);
$words[0][] = $lastword;
foreach(
$words[0] as $part) $uwords[] = ucfirst($part);
$text = implode("", $uwords);
echo
$text;
?>

<< Back to user notes page

To Top