3v4l.org

run code in 300+ PHP versions simultaneously
<?php // $array = ['Prinsha', 'Jypsy']; // echo $array[0]; // index is 0 // foreach($model as $key => $data) { // } // $array[1] = 'data'; // $array = ['model' => $model]; // $array = array(); // date('Y-m-d', strtotime("+3 days", $time)); $array = [1, 2, 3, 4]; echo $array[0] . "\n"; $associative = ['a' => '1', 'apple' => '3v4l', '1337' => 'PHP ']; echo $associative['a'] + 1 . "\n"; echo $associative['apple'] . "\n"; echo $associative[1337] . "\n"; $numbers = [1,2,3,4]; $numbers[] = 5; $numbers[] = 6; echo $numbers[0] . "\n"; //1 echo $numbers[4] . "\n"; // echo $numbers[5] . "\n"; $favColors = array(); $favColors[] = 'BlanchedAlmond'; $favColors[] = 'CadetBlue'; $favColors[] = 'BurlyWood'; $favColors[] = 'DarkOliveGreen'; $favColors[] = 'HotPink'; $favColors[] = 'Papayawhip'; echo $favColors[0] . "\n"; $matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ]; echo $matrix[1][2]; // 6 $alphabets = ['b', 'c', 'a', 'z', 'y']; foreach($alphabets as $alphabet) { echo $alphabet . "\n"; } sort($alphabets); echo 'After sorting...'; foreach($alphabets as $alphabet) { echo $alphabet . "\n"; }
Output for 7.0.0 - 7.0.20, 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.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
1 2 3v4l PHP 1 5 6 BlanchedAlmond 6b c a z y After sorting...a b c y z
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 1 2 3v4l PHP 1 5 6 BlanchedAlmond 6b c a z y After sorting...a b c y z

preferences:
161.79 ms | 402 KiB | 173 Q