3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); function containsString($str, $cont = array()) { $arr = ( ! is_array($cont)) ? array($cont) : $cont; // turn the string into an array foreach ($arr as $char) { var_dump($char);die(); if (strstr($str, $char)) { return true; } } return false; } function containsString_mlocati($str, $cont = array()) { $arr = is_array($cont) ? $cont : array($cont); foreach($arr as $item) { if(strstr($str, $item) !== false) { return true; } } return false; } $cont = 'Number of items: 0'; echo "Usually works:\n"; $str = 'not-existing'; var_dump(containsString($str, $cont)); var_dump(containsString_mlocati($str, $cont)); $str = 'items'; var_dump(containsString($str, $cont)); var_dump(containsString_mlocati($str, $cont)); echo "\n\n"; echo "**BUT:\n"; $str = '0'; var_dump(containsString($str, $cont)); var_dump(containsString_mlocati($str, $cont));
Output for git.master, git.master_jit, rfc.property-hooks
Usually works: string(18) "Number of items: 0"

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