3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $str = "categoryEnglishName:shouji dangers:(newuuid deep1条 IpCrossRule MobileCrossAreaRule) dangers:(FirstTimeImageRule OR DifferentIpmobledress) brid:(881581631eadc6e649b7dcb091a59396 OR 6dde9f581f114e2737bc56719990ec7a)"; if (preg_match_all('/([a-zA-Z]+)\:\(([^\)]+)\)/', $str, $m)) { for ($i = 0; $i < count($m[0]); $i++) { $q = trim($m[0][$i]); if (strlen($q) == 0) continue; $key = $m[1][$i]; $qq = preg_match('/[ OR | AND ]+/') ? $m[2][$i] : str_replace(" ", " AND ", $m[2][$i]); $qq = str_replace(array(" OR ", " AND "), array(" OR {$key}:", " AND {$key}:"), $qq); $str = str_replace($q, "({$key}:" . $qq. ")", $str); } } var_dump($str);
Output for 4.3.3 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Warning: preg_match() expects at least 2 parameters, 1 given in /in/DkQYp on line 9 Warning: preg_match() expects at least 2 parameters, 1 given in /in/DkQYp on line 9 Warning: preg_match() expects at least 2 parameters, 1 given in /in/DkQYp on line 9 string(293) "categoryEnglishName:shouji (dangers:newuuid AND dangers:deep1条 AND dangers:IpCrossRule AND dangers:MobileCrossAreaRule) (dangers:FirstTimeImageRule AND dangers:OR dangers:AND DifferentIpmobledress) (brid:881581631eadc6e649b7dcb091a59396 AND brid:OR brid:AND 6dde9f581f114e2737bc56719990ec7a)"
Output for 4.3.0 - 4.3.2
Warning: Wrong parameter count for preg_match() in /in/DkQYp on line 9 Warning: Wrong parameter count for preg_match() in /in/DkQYp on line 9 Warning: Wrong parameter count for preg_match() in /in/DkQYp on line 9 string(293) "categoryEnglishName:shouji (dangers:newuuid AND dangers:deep1条 AND dangers:IpCrossRule AND dangers:MobileCrossAreaRule) (dangers:FirstTimeImageRule AND dangers:OR dangers:AND DifferentIpmobledress) (brid:881581631eadc6e649b7dcb091a59396 AND brid:OR brid:AND 6dde9f581f114e2737bc56719990ec7a)"