3v4l.org

run code in 300+ PHP versions simultaneously
<?php $file = '2014_10_12_100000_create_password_resets_table'; // Create array of all parts... $steps['explode'] = explode('_', $file); // The expected datetime format as 4 parts, so we remove the first 4 elements and keep the rest. $steps['slice'] = array_slice($steps['explode'], 4); // Implode the remaining elements back together into a snake_case string. $steps['implode'] = implode('_', $steps['slice']); // Convert the snake_case string to a StudlyCase class name. $steps['class'] = studly_case($steps['implode']); var_dump($steps); function studly_case($value) { $value = ucwords(str_replace(['-', '_'], ' ', $value)); return str_replace(' ', '', $value); }
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.29, 8.4.1 - 8.4.14, 8.4.16 - 8.4.17, 8.5.0 - 8.5.2
array(4) { ["explode"]=> array(8) { [0]=> string(4) "2014" [1]=> string(2) "10" [2]=> string(2) "12" [3]=> string(6) "100000" [4]=> string(6) "create" [5]=> string(8) "password" [6]=> string(6) "resets" [7]=> string(5) "table" } ["slice"]=> array(4) { [0]=> string(6) "create" [1]=> string(8) "password" [2]=> string(6) "resets" [3]=> string(5) "table" } ["implode"]=> string(28) "create_password_resets_table" ["class"]=> string(25) "CreatePasswordResetsTable" }
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
215.89 ms | 408 KiB | 5 Q