3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_last_dot_occurence ($url ) { $fullArray = explode('.', $url); $newArray = ""; switch (count($fullArray)) { case 1: $newArray = $url; break; case 2: $newArray = array("string1" => $fullArray[0], "string2" => $fullArray[1]); break; default: $string1 = ""; for ($i=0; $i < count($fullArray)-2; $i++) { $string1 .= $fullArray[$i]; if($i != count($fullArray)-3) $string1 .= '.'; } $string2 = $fullArray[count($fullArray)-2].'.'.$fullArray[count($fullArray)-1]; $newArray = array("string1" => $string1, "string2" => $string2); break; } return $newArray; } print_r(get_last_dot_occurence("abc.com")); print_r(get_last_dot_occurence("abc.name.com")); print_r(get_last_dot_occurence("abc.xyz.name.org"));
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [string1] => abc [string2] => com ) Array ( [string1] => abc [string2] => name.com ) Array ( [string1] => abc.xyz [string2] => name.org )

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