3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_phrases($sentence) { $inQuotes = false; $quoteChars = ['"', "'"]; $separators = [' ', "\n"]; $phrase = null; foreach ((string) $sentence as $i => $t) { if (!$inQuotes && in_array($t, $quoteChars)) { // Opening quote $inQuotes = $t; } elseif ($inQuotes && $t == $inQuotes) { // Closing quote $inQuotes = false; } elseif (!$inQuotes && in_array($t, $separators)) { yield $phrase; // or add to an array in pre-5.5 $phrase = null; } else { $phrase .= $t; } } } var_dump(get_phrases('Hello world')); var_dump(get_phrases("I am a 'foo bar'"));
Output for git.master, git.master_jit, rfc.property-hooks
object(Generator)#1 (0) { } object(Generator)#1 (0) { }

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