Revision 7a2b1657-ecd2-483b-bddb-a470dd877358 - Code Golf Stack Exchange
PHP7.4 (79 chars)
-
The function **$f** is inverting the last two chars of every word :
```php
$f=fn($s)=>preg_replace_callback('#(\S)(\S)($|\s)#u',fn($a)=>"$a[2]$a[1] ",$s);
```
Usage :
```php
echo $f('Flippign Lettesr Aroudn');
```
The PHP7.4 [CLI](https://www.php.net/manual/en/features.commandline.php) equivalent (**79 chars**) is expecting *$argv[1]* to be a given string :
```php
echo preg_replace_callback('#(\S)(\S)($|\s)#u',fn($a)=>"$a[2]$a[1] ",$argv[1]);
```
Both are using the `u` modifier so it's [PCRE_UTF8](https://www.php.net/manual/en/reference.pcre.pattern.modifiers.php) compatible.
PHP 5.3 CLI (**86 chars**)
-
Given *$argv[1]* as a command line argument.
```php
for($i=0,$a="$argv[1] ";@$a[$i];)echo$a[$i+2]==' '?$a[1+$i].$a[-3+$i+=3].' ':$a[$i++];
```
**Info** : The notice should be silenced by the [@](https://www.php.net/manual/en/language.operators.errorcontrol.php).