3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'filesystem-2.4.0-1 comps-extras-11.1-1.1 gnome-mime-data-2.4.2-3.1 glibc-2.5-12 atk-1.12.2-1.fc6 libICE-1.0.1-2.1 db4-4.3.29-9.fc6 elfutils-libelf-0.125-3.el5 ncurses-5.5-24.20060715 libsepol-1.15.2-1.el5 libcap-1.10-26 sqlite-3.3.6-2 pcre-6.6-1.1 gdbm-1.8.0-26.2.1 libsepol-1.15.2-1.el5 libXdmcp-1.0.1-2.1 db4-4.3.29-9.fc6 iptables-1.3.5-1.2.1 libXrender-0.9.1-3.1 libXi-1.0.1-3.1 xorg-x11-font-utils-7.1-2 slang-2.0.6-4.el'; $array = explode(PHP_EOL, $str); array_walk($array, function(&$value, $key) { preg_match('/-\d/', $value, $match, PREG_OFFSET_CAPTURE); $offset = !empty($match) ? $match[0][1] : strlen($value); $value = [ 'name' => substr($value, 0, $offset), 'version' => trim(substr($value, $offset), '-') ]; }); print_r($array);
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.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
Array ( [0] => Array ( [name] => filesystem [version] => 2.4.0-1 ) [1] => Array ( [name] => comps-extras [version] => 11.1-1.1 ) [2] => Array ( [name] => gnome-mime-data [version] => 2.4.2-3.1 ) [3] => Array ( [name] => glibc [version] => 2.5-12 ) [4] => Array ( [name] => atk [version] => 1.12.2-1.fc6 ) [5] => Array ( [name] => libICE [version] => 1.0.1-2.1 ) [6] => Array ( [name] => db4 [version] => 4.3.29-9.fc6 ) [7] => Array ( [name] => elfutils-libelf [version] => 0.125-3.el5 ) [8] => Array ( [name] => ncurses [version] => 5.5-24.20060715 ) [9] => Array ( [name] => libsepol [version] => 1.15.2-1.el5 ) [10] => Array ( [name] => libcap [version] => 1.10-26 ) [11] => Array ( [name] => sqlite [version] => 3.3.6-2 ) [12] => Array ( [name] => pcre [version] => 6.6-1.1 ) [13] => Array ( [name] => gdbm [version] => 1.8.0-26.2.1 ) [14] => Array ( [name] => libsepol [version] => 1.15.2-1.el5 ) [15] => Array ( [name] => libXdmcp [version] => 1.0.1-2.1 ) [16] => Array ( [name] => db4 [version] => 4.3.29-9.fc6 ) [17] => Array ( [name] => iptables [version] => 1.3.5-1.2.1 ) [18] => Array ( [name] => libXrender [version] => 0.9.1-3.1 ) [19] => Array ( [name] => libXi [version] => 1.0.1-3.1 ) [20] => Array ( [name] => xorg-x11-font-utils [version] => 7.1-2 ) [21] => Array ( [name] => slang [version] => 2.0.6-4.el ) )
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:
206.9 ms | 409 KiB | 5 Q