3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $ad = "123 Main Street St. Louisville OH 43071,432 Main Long Road St. Louisville OH 43071,786 High Street Pollocksville NY 56432," ."54 Holy Grail Street Niagara Town ZP 32908,3200 Main Rd. Bern AE 56210,1 Gordon St. Atlanta RE 13000," ."10 Pussy Cat Rd. Chicago EX 34342,10 Gordon St. Atlanta RE 13000,58 Gordon Road Atlanta RE 13000," ."22 Tokyo Av. Tedmondville SW 43098,674 Paris bd. Abbeville AA 45521,10 Surta Alley Goodtown GG 30654," ."45 Holy Grail Al. Niagara Town ZP 32908,320 Main Al. Bern AE 56210,14 Gordon Park Atlanta RE 13000," ."100 Pussy Cat Rd. Chicago EX 34342,2 Gordon St. Atlanta RE 13000,5 Gordon Road Atlanta RE 13000," ."2200 Tokyo Av. Tedmondville SW 43098,67 Paris St. Abbeville AA 45521,11 Surta Avenue Goodtown GG 30654," ."45 Holy Grail Al. Niagara Town ZP 32918,320 Main Al. Bern AE 56215,14 Gordon Park Atlanta RE 13200," ."100 Pussy Cat Rd. Chicago EX 34345,2 Gordon St. Atlanta RE 13222,5 Gordon Road Atlanta RE 13001," ."2200 Tokyo Av. Tedmondville SW 43198,67 Paris St. Abbeville AA 45522,11 Surta Avenue Goodville GG 30655," ."2222 Tokyo Av. Tedmondville SW 43198,670 Paris St. Abbeville AA 45522,114 Surta Avenue Goodville GG 30655," ."2 Holy Grail Street Niagara Town ZP 32908,3 Main Rd. Bern AE 56210,77 Gordon St. Atlanta RE 13000"; function travel($r, $zipcode) { $fullAddress = explode( "," , $r ); $filteredAddress = preg_grep("/".$zipcode."$/" , $fullAddress); $splitAddress = array_reduce( $filteredAddress , function($total, $current) { preg_match_all( "/^[0-9]+ |.*(?=[A-Z]{2} [0-9]{5}$)/" , $current , $matches ); array_push($total, [trim($matches[0][0]) , trim($matches[0][1])]); return $total; } , [] ); // print_r($splitAddress); print_r(array_reduce($splitAddress , function ($streets , $street) { $streets[] = $street[1]; return $streets;} , []) ); return $zipcode .":/" .array_reduce($splitAddress , function ($streets , $street) { return $streets . "," . $street[1];} , "") ."/" .array_reduce($splitAddress , function ($streetNos , $street) { return $streetNos . "," . $street[0];} , ""); } echo(travel($ad, "AA 45522"));
based on Q0oFT
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.3.0alpha1
Array ( [0] => Paris St. Abbeville [1] => Paris St. Abbeville ) AA 45522:/,Paris St. Abbeville,Paris St. Abbeville/,67,670