3v4l.org

run code in 300+ PHP versions simultaneously
<?php function in_arrayi($needle, array $haystack, bool $strict = false): bool { if (!is_scalar($needle)) { // throw exception or something because of unsuitable data type } $needle = strtolower($needle); foreach ($haystack as $value) { if (!is_scalar($value)) { continue; } elseif ($strict && strtolower($value) === $needle) { return true; } elseif (!$strict && strtolower($value) == $needle) { return true; } } return false; } $haystack = array('one', 'two', 'three', 'four'); $test_needles = ['onE', 'tWo', 'THREE', 'four', 'five']; foreach ($test_needles as $needle) { echo $needle . ': ' . (in_arrayi($needle, $haystack) ? 'found' : 'missing') . "\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
onE: found tWo: found THREE: found four: found five: missing

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