3v4l.org

run code in 300+ PHP versions simultaneously
<?php $csv_specie = array("Mouse","Human"); $CDNA = 'Human interleukin 2 (IL2)a;Ampicillin resistance gene (amp)a;Mouse amp gene;Some other stuff unknown to man kind;some other human stuff'; $cdna = explode(";", $CDNA); Foreach($csv_specie as $specie){ $matches[$specie] = preg_grep("/\b" . $specie . "\b/i", $cdna); Echo $specie . " - " . implode("\n" . $specie . " - " , $matches[$specie]) . "\n"; // Remove matched items from $cdna $cdna = array_diff($cdna, $matches[$specie]); } // What is left in $cdna is not matched $matches["N/A"] = $cdna; Echo "\nN/A - " . implode("\nN/A - ", $matches["N/A"]); Echo "\n\n"; Var_dump($matches);
Output for 7.1.0 - 7.1.25, 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.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.4.16, 8.5.0 - 8.5.1
Mouse - Mouse amp gene Human - Human interleukin 2 (IL2)a Human - some other human stuff N/A - Ampicillin resistance gene (amp)a N/A - Some other stuff unknown to man kind array(3) { ["Mouse"]=> array(1) { [2]=> string(14) "Mouse amp gene" } ["Human"]=> array(2) { [0]=> string(26) "Human interleukin 2 (IL2)a" [4]=> string(22) "some other human stuff" } ["N/A"]=> array(2) { [1]=> string(33) "Ampicillin resistance gene (amp)a" [3]=> string(36) "Some other stuff unknown to man kind" } }
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:
195.19 ms | 408 KiB | 5 Q