3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function getSearchResult($str, $query, $numOfWordToAdd) { $lowered = strtolower($query); $str = str_replace($query,$lowered,$str); var_dump(array('lowered' => $lowered, 'str' => $str)); list($before, $after) = explode($lowered, $str); } $body = "<p>This is the body, KeyWoRd to be searched is here.</p>"; $keyword = "keyword"; echo getSearchResult($body,$keyword,1); ?>
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
array(2) { ["lowered"]=> string(7) "keyword" ["str"]=> string(56) "<p>This is the body, KeyWoRd to be searched is here.</p>" } Notice: Undefined offset: 1 in /in/01CjO on line 8
Output for hhvm-3.10.0 - 3.12.0
array(2) { ["lowered"]=> string(7) "keyword" ["str"]=> string(56) "<p>This is the body, KeyWoRd to be searched is here.</p>" } Notice: Undefined index: 1 in /in/01CjO on line 8
Output for 4.3.0 - 5.2.17
array(2) { ["lowered"]=> string(7) "keyword" ["str"]=> string(56) "<p>This is the body, KeyWoRd to be searched is here.</p>" } Notice: Undefined offset: 1 in /in/01CjO on line 8