3v4l.org

run code in 300+ PHP versions simultaneously
<?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 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.29, 8.2.0 - 8.2.21, 8.3.0 - 8.3.9
F(Mytable)F(Mytable)F(Mytable)F(Mytable)

preferences:
144.84 ms | 405 KiB | 167 Q