3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function removeCacheWhereLike($sClass, $aWhere) { $aWhereQueryStrings = ''; foreach ($aWhere as $sKey => $sValue) { $aWhereQueryStrings[] = "`Query` LIKE '%\"".$sKey."\":\"".$sValue."\"%'"; } if (empty($aWhereQueryStrings)) { return false; } return " SELECT `Query` FROM IrgentEineTabelle WHERE ".implode(' AND', $aWhereQueryStrings)." "; } echo removeCacheWHereLike('Amazon', array( 'Function' => __FUNCTION__, 'Category' => 'CATEGORY', 'MWSSite' => 'DE', ));
based on 1AI6S
Output for 7.1.0 - 7.3.0
Fatal error: Uncaught Error: [] operator not supported for strings in /in/X3U4d:7 Stack trace: #0 /in/X3U4d(22): removeCacheWhereLike('Amazon', Array) #1 {main} thrown in /in/X3U4d on line 7
Process exited with code 255.
Output for 5.6.0 - 5.6.38, hhvm-3.15.4, 7.0.0 - 7.0.33
SELECT `Query` FROM IrgentEineTabelle WHERE `Query` LIKE '%"Function":""%' AND`Query` LIKE '%"Category":"CATEGORY"%' AND`Query` LIKE '%"MWSSite":"DE"%'