3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $result = new stdclass(); $result->introtext = "<p class=\"text_titel_ohne_autor\">Spoiler!</p>"; if(strpos($result->introtext, "<p class=\"text_titel\"") !== false){ $titleStart = strpos($result->introtext, "<p class=\"text_titel\">") + 22; $titleEnd = strpos($result->introtext, "</p>", $titleStart); $result->maintitle = strip_tags(substr($result->introtext, $titleStart, $titleEnd - $titleStart)); } else if(strpos($result->introtext, "<p class=\"text_titel_ohne_autor\"") !== false){ $titleStart = strpos($result->introtext, "<p class=\"text_titel_ohne_autor\">") + 33; $titleEnd = strpos($result->introtext, "</p>", $titleStart); $result->maintitle = strip_tags(substr($result->introtext, $titleStart, $titleEnd - $titleStart)); } else if(strpos($result->introtext, "<span class=\"text_titel\">") !== false){ $titleStart = strpos($result->introtext, "<span class=\"text_titel\">") + 25; $titleEnd = strpos($result->introtext, "</span>", $titleStart); $result->maintitle = strip_tags(substr($result->introtext, $titleStart, $titleEnd - $titleStart)); } echo $result->maintitle;
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Spoiler!