3v4l.org

run code in 300+ PHP versions simultaneously
<?php function str_to_address($context) { $array = explode(" ", $context); $array_reversed = array_reverse($array); $numKey = ""; $zipKey = ""; foreach($array_reversed as $k=>$str) { if($zipKey) { continue; } if(strlen($str)===5 && is_numeric($str)) { $zipKey = $k; } } $array_reversed = array_slice($array_reversed, $zipKey); $array = array_reverse($array_reversed); foreach($array as $k=>$str) { if($numKey) { continue; } if(strlen($str)>1 && strlen($str)<6 && is_numeric($str)) { $numKey = $k; } } $array = array_slice($array, $numKey); $string = implode(' ', $array); return $string; } echo str_to_address("Sally sells seashells at 452 Parks Way, Lemons, GA 45243 and loves it."); ?>
Output for git.master, git.master_jit, rfc.property-hooks
452 Parks Way, Lemons, GA 45243

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
37.34 ms | 401 KiB | 8 Q