3v4l.org

run code in 200+ PHP versions simultaneously
<?php $subscriberTags = json_decode('{"hu":2174325}'); $availableTags = json_decode('{"cz":2174305,"hu":2174325,"at":2174333,"de":2174353,"pl":2174365,"sk":2174373,"gb":2174381,"nl":2174385,"gr":2174877,"ru":2174881}'); $actualSubscriberTags = []; $addTags = []; $removeTags = []; foreach (['us', 'hu'] as $offer) { $actualSubscriberTags[] = $country; if (!array_key_exists($country, $subscriberTags) && !in_array($country, $addTags)) { $addTags[] = $country; } } foreach (array_keys($subscriberTags) as $tag) { if (!in_array($tag, $actualSubscriberTags) && !in_array($tag, $removeTags)) { $removeTags[] = $tag; } } foreach ($addTags as $tag) { if (!array_key_exists($tag, $availableTags)) { $return = $this->baseService->createTag(self::LIST_ID_LANDLORDS, $tag); $availableTags[$tag] = $return['id']; } echo 'ADD ' . $availableTags[$tag] . PHP_EOL; } foreach ($removeTags as $tag) { echo 'REMOVE ' . $availableTags[$tag] . PHP_EOL; }
Output for 7.4.0 - 7.4.2
Notice: Undefined variable: country in /in/BGZmP on line 12 Deprecated: array_key_exists(): Using array_key_exists() on objects is deprecated. Use isset() or property_exists() instead in /in/BGZmP on line 14 Notice: Undefined variable: country in /in/BGZmP on line 14 Notice: Undefined variable: country in /in/BGZmP on line 14 Notice: Undefined variable: country in /in/BGZmP on line 15 Notice: Undefined variable: country in /in/BGZmP on line 12 Deprecated: array_key_exists(): Using array_key_exists() on objects is deprecated. Use isset() or property_exists() instead in /in/BGZmP on line 14 Notice: Undefined variable: country in /in/BGZmP on line 14 Notice: Undefined variable: country in /in/BGZmP on line 14 Warning: array_keys() expects parameter 1 to be array, object given in /in/BGZmP on line 19 Warning: Invalid argument supplied for foreach() in /in/BGZmP on line 19 Deprecated: array_key_exists(): Using array_key_exists() on objects is deprecated. Use isset() or property_exists() instead in /in/BGZmP on line 26 Fatal error: Uncaught Error: Using $this when not in object context in /in/BGZmP:27 Stack trace: #0 {main} thrown in /in/BGZmP on line 27
Process exited with code 255.
Output for 7.2.0 - 7.3.14
Notice: Undefined variable: country in /in/BGZmP on line 12 Notice: Undefined variable: country in /in/BGZmP on line 14 Notice: Undefined variable: country in /in/BGZmP on line 14 Notice: Undefined variable: country in /in/BGZmP on line 15 Notice: Undefined variable: country in /in/BGZmP on line 12 Notice: Undefined variable: country in /in/BGZmP on line 14 Notice: Undefined variable: country in /in/BGZmP on line 14 Warning: array_keys() expects parameter 1 to be array, object given in /in/BGZmP on line 19 Warning: Invalid argument supplied for foreach() in /in/BGZmP on line 19 Fatal error: Uncaught Error: Using $this when not in object context in /in/BGZmP:27 Stack trace: #0 {main} thrown in /in/BGZmP on line 27
Process exited with code 255.