3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getCode($string) { $code = 0; if (preg_match('/\bred\b/i', $string)) { $code += 2; } if (preg_match('/\bblue\b/i', $string)) { $code += 3; } if (preg_match('/\bgreen\b/i', $string)) { $code += 4; } if ($code === 9) { $code += 2; } if ($code) { return $code; } if (preg_match('/\bballoon\b/i', $string)) { return 1; } return 0; } $sentences = [ 'Here is a green, blue, and red balloon', 'A blue balloon here', 'A red herring', 'Blue is the name of my dog', 'Red and green are Xmas colors', 'blue skies over green grass', 'Foo is bar', 'Have a balloon and a balloon and a balloon', 'A green balloon', 'A blue balloon with a red string', ]; foreach ($sentences as $sentence) { printf("%s => %d\n", $sentence, getCode($sentence)); }
Output for git.master, git.master_jit, rfc.property-hooks
Here is a green, blue, and red balloon => 11 A blue balloon here => 3 A red herring => 2 Blue is the name of my dog => 3 Red and green are Xmas colors => 6 blue skies over green grass => 7 Foo is bar => 0 Have a balloon and a balloon and a balloon => 1 A green balloon => 4 A blue balloon with a red string => 5

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:
165.91 ms | 406 KiB | 5 Q