3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Deciphering this peculiar line Laravel's Migrator.php - Str::studly(implode('_', array_slice(explode('_', $file), 4))); * * I'm probably being dumb, but I can't for the life of me work out.. * well, how it would ever work. * * https://github.com/laravel/framework/blame/5.5/src/Illuminate/Database/Migrations/Migrator.php#L415 */ $testCase = '01234567_create_mycool_table.php'; // Break in to chunks $testCase = explode('_', $testCase); var_dump($testCase); // Slice... Presumably to take the timestamp off. (So, array_slice($str, 1, 4)... oh?) $testCase = array_slice($testCase, 4); var_dump($testCase); // Implode.. with underscores again. (Surely substr($str, 0, strpos($str, '_')-1) would be easier?) // It doesn't matter, as unless we have a_really_long_file_name; this will be empty anyway.. $testCase = implode('_', $testCase); var_dump($testCase); // Studly converts to camelcase based upon the placement of '_';
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.34, 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) { [0]=> string(8) "01234567" [1]=> string(6) "create" [2]=> string(6) "mycool" [3]=> string(9) "table.php" } array(0) { } string(0) ""
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:
161.45 ms | 407 KiB | 5 Q