3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $data = [ 'MY_TABLE' => 'MyTable', 'MyTable' => 'MyTable', 'my_table' => 'MyTable', 'myTable' => 'MyTable', ]; function yiiCamelize($word) { return str_replace(' ', '', ucwords(preg_replace('/[^\pL\pN]+/u', ' ', $word))); } function camelCaseIt($input) { return strtr(ucwords(implode(' ', explode('_', strtolower(strtr(yiiCamelize($input), [' ' => '_']))))), [' ' => '']); } foreach ($data as $input => $expected) { $actual = camelCaseIt($input); if ($actual === $expected) { echo '.'; } else { echo 'F(' . $actual . ')'; } }
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.1.0 - 7.3.0rc3
F(Mytable)F(Mytable)F(Mytable)F(Mytable)