3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = '<p class="example">example</p> <p class="example" style="visibility:hidden">example</p> <script type="text/javascript">var example = 1 ....other stuff.... </script>'; $arr = explode(PHP_EOL, $str); for($i = 0; $i < count($arr); $i++){ if(strpos("hidden", $arr[$i]) === false){ unset($arr[$i]); } if(strpos("<script", $arr[$i]) === false){ while(!strpos("</script", $arr[$i]) === false){ unset($arr[$i]); $i++; } } } $str = implode(PHP_EOL, $arr); Echo substr_count(strip_tags($str), "example");
Output for 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Warning: Undefined array key 0 in /in/YMd7q on line 15 Deprecated: strpos(): Passing null to parameter #2 ($needle) of type string is deprecated in /in/YMd7q on line 15 Warning: Undefined array key 1 in /in/YMd7q on line 15 Deprecated: strpos(): Passing null to parameter #2 ($needle) of type string is deprecated in /in/YMd7q on line 15 Warning: Undefined array key 2 in /in/YMd7q on line 15 Deprecated: strpos(): Passing null to parameter #2 ($needle) of type string is deprecated in /in/YMd7q on line 15 0
Output for 8.0.0 - 8.0.30
Warning: Undefined array key 0 in /in/YMd7q on line 15 Warning: Undefined array key 1 in /in/YMd7q on line 15 Warning: Undefined array key 2 in /in/YMd7q on line 15 0
Output for 7.3.0 - 7.3.31, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
Notice: Undefined offset: 0 in /in/YMd7q on line 15 Deprecated: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in /in/YMd7q on line 15 Notice: Undefined offset: 0 in /in/YMd7q on line 16 Deprecated: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in /in/YMd7q on line 16 Notice: Undefined offset: 1 in /in/YMd7q on line 15 Deprecated: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in /in/YMd7q on line 15 Notice: Undefined offset: 1 in /in/YMd7q on line 16 Deprecated: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in /in/YMd7q on line 16 Notice: Undefined offset: 2 in /in/YMd7q on line 15 Deprecated: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in /in/YMd7q on line 15 Notice: Undefined offset: 2 in /in/YMd7q on line 16 Deprecated: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in /in/YMd7q on line 16 0
Output for 7.3.32 - 7.3.33, 7.4.26
0
Output for 5.6.38, 7.0.0 - 7.0.33, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33
Notice: Undefined offset: 0 in /in/YMd7q on line 15 Notice: Undefined offset: 0 in /in/YMd7q on line 16 Notice: Undefined offset: 1 in /in/YMd7q on line 15 Notice: Undefined offset: 1 in /in/YMd7q on line 16 Notice: Undefined offset: 2 in /in/YMd7q on line 15 Notice: Undefined offset: 2 in /in/YMd7q on line 16 0

preferences:
187.57 ms | 402 KiB | 213 Q