3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = ' John David James (DEM) . . . . . . 7,808 10.51 Marvin D. Scott (DEM) . . . . . . 6,548 9.55 Maria "Mary" Williams (DEM) . . . . 4,551 8.58 Dwayne R. Johnson. . . . . . . . 4,322 8.22 WRITE-IN. . . . . . . . . . . 188 .29'; preg_match_all("/\s*(.*?)\s*\. \..*?([\d,]+)/", $str, $matches); foreach($matches[1] as $key => $name){ $new[] = $name . "," . str_replace(",", "", $matches[2][$key]); } Var_dump($new);
Output for 5.6.38, 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.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
array(5) { [0]=> string(27) "John David James (DEM),7808" [1]=> string(26) "Marvin D. Scott (DEM),6548" [2]=> string(32) "Maria "Mary" Williams (DEM),4551" [3]=> string(22) "Dwayne R. Johnson,4322" [4]=> string(12) "WRITE-IN,188" }
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 array(5) { [0]=> string(27) "John David James (DEM),7808" [1]=> string(26) "Marvin D. Scott (DEM),6548" [2]=> string(32) "Maria "Mary" Williams (DEM),4551" [3]=> string(22) "Dwayne R. Johnson,4322" [4]=> string(12) "WRITE-IN,188" }

preferences:
166.62 ms | 402 KiB | 179 Q