3v4l.org

run code in 300+ PHP versions simultaneously
<?php function do_split($name) { return preg_split('/([A-Z]{2,}|([A-Z][^A-Z]*))/', $name, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); } function convert_case($name) { return implode( '_', array_map( 'strtolower', do_split($name) ) ); } function convert_case2($name) { $output = ''; for ($i=0; $i<strlen($name); $i++) { $char = $name[$i]; print_r("{$char} " . json_encode(ctype_upper($char))); } return strtolower($output); } convert_case2('FooBARbar'); $samples = array( 'FooBar', 'FooBAR', 'FOObar', 'foo_bar', 'FOO_bar', 'foo_BAR', 'foo_Bar', 'Foo_bar', ); /* print_r(array_map(function ($name) { return array( 'name' => $name, 'split' => do_split($name), 'converted' => convert_case($name), ); }, $samples)); */
Output for git.master, git.master_jit, rfc.property-hooks
F trueo falseo falseB trueA trueR trueb falsea falser false

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:
85.78 ms | 401 KiB | 8 Q