DEV Community

loading...

Discussion on: Daily Challenge #15 - Stop gninnipS My sdroW!

Collapse
p810 profile image
Payton Bice • Edited

PHP 5.3.0 to 7.3.x:

preg_replace_callback('/(\b\w{5,}\b)+/i', function ($match) {
    return strrev($match[0]);
}, 'Hello world, this is a test string.');

PHP >= 7.4:

preg_replace_callback('/(\b\w{5,}\b)+/i', fn($match) => strrev($match[0]), 'Hello world, this is a test string.');