3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ConvertToAPICase($str) { return preg_replace_callback('/^([a-z]{1})|(-([\w]{1}))/g', function($matches) { return strtoupper($matches[1]); }, $str); } function ConvertToJSCase($str) { $str = preg_replace_callback('/([A-Z]+)/g', function($matches) { return '-' . strtolower($matches[1]); }, $str); // remove first dash return preg_replace('/^-/', '', $str); } echo ConvertToJSCase('NicamAllAges'); echo ' - '; echo ConvertToAPICase('nicam-age-6'); echo ' - '; echo ConvertToJSCase('NicamAge6'); echo ' - '; echo ConvertToJSCase('nicamAge12'); echo ' - '; echo ConvertToJSCase('NicamAA');
Output for git.master, git.master_jit, rfc.property-hooks
Warning: preg_replace_callback(): Unknown modifier 'g' in /in/nkFao on line 10 Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /in/nkFao on line 15 - Warning: preg_replace_callback(): Unknown modifier 'g' in /in/nkFao on line 4 - Warning: preg_replace_callback(): Unknown modifier 'g' in /in/nkFao on line 10 Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /in/nkFao on line 15 - Warning: preg_replace_callback(): Unknown modifier 'g' in /in/nkFao on line 10 Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /in/nkFao on line 15 - Warning: preg_replace_callback(): Unknown modifier 'g' in /in/nkFao on line 10 Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /in/nkFao on line 15

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:
44.36 ms | 403 KiB | 8 Q