3v4l.org

run code in 300+ PHP versions simultaneously
<?PHP $str = " Monday Tuesday Wednesday Thursday Friday\nSaturday\tSunday"; function a($str) { return str_word_count($str,1,"!\"#$%&'()*+,./0123456789-:;<=>?@[\]^_`{|}~"); }; function c($str) { return preg_split("/\s+/",trim($str)); }; function d($string){ return array_filter(explode(' ', implode(' ', array_map('trim', explode("\n", $string))))); }; function e($str) { $str = trim($str); $words = array(); $len = strlen($str); $word = ''; for ($i = 0; $i < $len; $i++) { $char = $str[$i]; $ord = ord($char); // Is a character if ($ord > 32 && $ord < 127) { $word .= $char; // It's some sort of whitespace } else { if ($word) { $words[] = $word; } $word = ''; } } if ($word) { $words[] = $word; } return $words; }; function f($str,$return_hash = false) { $str = trim($str); // Word characters are any printable char $words = str_word_count($str,1,"!\"#$%&'()*+,./0123456789-:;<=>?@[\]^_`{|}~"); if ($return_hash) { $ret = array(); $num = sizeof($words); // Odd number of elements, can't build a hash if ($num % 2 == 1) { return array(); } else { // Loop over each word and build a key/value hash for ($i = 0; $i < $num; $i += 2) { $key = $words[$i]; $value = $words[$i + 1]; $ret[$key] = $value; } return $ret; } } else { return $words; } }; ////////////(////////////////////////////////////////////////////////////////// a($str); c($str); d($str); e($str); f($str);
Output for git.master, git.master_jit, rfc.property-hooks

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