3v4l.org

run code in 300+ PHP versions simultaneously
<?php function plural_to_singular($string) { // quick return of "un-convertibles" if(preg_match('~^(?:[oó]culos|parab[eé]ns|f[eé]rias)$~iu', $string)) { return $string; } $regex_config = [ '~[õã]es$~iu' => 'ão', '~[áó].*eis$~iu' => 'el', '~[eé]is$~iu' => 'el', '~[^eé]\Kis$~iu' => 'l', '~ns$~iu' => 'm', '~eses$~iu' => 'ês', '~[rzs]\Kes$~iu' => '', '~s$~iu' => '' ]; return preg_replace(array_keys($regex_config), $regex_config, $string, 1); } $words = array( 'papéis' => 'papel', 'anéis' => 'anel', 'PASTEIS' => 'PASTEL', 'CAMIÕES' => 'CAMIÃO', 'rodas' => 'roda', 'cães' => 'cão', 'meses' => 'mês', 'vezes' => 'vez', 'luzes' => 'luz', 'cristais' => 'cristal', 'canções' => 'canção', 'nuvens' => 'nuvem', 'alemães' => 'alemão' ); foreach($words as $plural => $singular) { echo "$plural => $singular = " , plural_to_singular($plural) , "\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
papéis => papel = papel anéis => anel = anel PASTEIS => PASTEL = PASTel CAMIÕES => CAMIÃO = CAMIão rodas => roda = roda cães => cão = cão meses => mês = mê vezes => vez = vez luzes => luz = luz cristais => cristal = cristal canções => canção = canção nuvens => nuvem = nuvem alemães => alemão = alemão

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
129.61 ms | 406 KiB | 5 Q