3v4l.org

run code in 300+ PHP versions simultaneously
<?php function fixAddress($address) { $address = trim($address); $addr_words = str_word_count($address, 1, "/',.-$#@&*!+=0123456789"); $addr_line1 = ''; foreach ($addr_words as $word) { if(strlen($addr_line1.' '.$word) <= 30) { $addr_line1 .= ' '.$word; array_shift($addr_words); } else { break; } } $addr_line2 = ''; if(!empty($addr_words)) { $addr_line2 = substr(implode(' ', $addr_words), 0, 30); } return array('addr_line1'=>trim($addr_line1), 'addr_line2'=>trim($addr_line2)); } $t = fixAddress('201 12th Street South, South, $word'); print_r($t); exit;
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [addr_line1] => 201 12th Street South, South, [addr_line2] => $word )

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:
61.47 ms | 401 KiB | 8 Q