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);

preferences:
17.62 ms | 402 KiB | 5 Q