3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function strpose($haystack, $needle, $index = 0) { do { $pos = strpos($haystack, $needle, $index); if ($pos !== false) { if (!@trim($haystack[$pos-1])) { if (!@trim($haystack[($pos+strlen($needle))])) { return $pos; } else $index = $pos+1; } else $index = $pos+1; } } while ($pos !== false && $pos < strlen($haystack)); return $pos; } var_dump(strpose("Hello World", "ll")); var_dump(strpose("Hello World", "Hello")); var_dump(strpose("Hello Worlds", "World")); ?>
Output for 7.1.0
bool(false) bool(false) bool(false)
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.0.14
bool(false) int(0) bool(false)