3v4l.org

run code in 300+ PHP versions simultaneously
<?php function split_name($fullname) { $firstname = ""; $surname = ""; $pieces = explode(" ", $fullname); foreach ($pieces as $name) { if (ctype_upper(filter_var(str_replace("'", "", $name), FILTER_SANITIZE_STRING))) $surname .= $name." "; else $firstname .= $name. " "; } return array("firstname" => $firstname, "surname" => $surname); } $names = array("Jack David SMITH", "Pietro DE GIOVANNI", "Jane JOHNSON", "Matthew O'RILEY", "John-Paul JOHNSON"); $split = array_map("split_name", $names); print_r($split);
Output for git.master_jit, git.master, rfc.property-hooks
Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /in/JXp2s on line 9 Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /in/JXp2s on line 9 Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /in/JXp2s on line 9 Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /in/JXp2s on line 9 Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /in/JXp2s on line 9 Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /in/JXp2s on line 9 Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /in/JXp2s on line 9 Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /in/JXp2s on line 9 Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /in/JXp2s on line 9 Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /in/JXp2s on line 9 Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /in/JXp2s on line 9 Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /in/JXp2s on line 9 Array ( [0] => Array ( [firstname] => Jack David [surname] => SMITH ) [1] => Array ( [firstname] => Pietro [surname] => DE GIOVANNI ) [2] => Array ( [firstname] => Jane [surname] => JOHNSON ) [3] => Array ( [firstname] => Matthew [surname] => O'RILEY ) [4] => Array ( [firstname] => John-Paul [surname] => JOHNSON ) )

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:
35.75 ms | 410 KiB | 5 Q