3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tags = ' #vienna #wien #austria #view #travel #sky #holiday #vacation #ig_europe #landmark #reflections #ocean #europe #sky #reflection #water #people #sea #pretty #fun #beach #lighthouse #cliff #topeuropephotos #photo #photos #cloud #stone #sunset ' ; $pcs = array_map('trim', explode('#', $tags)); $found=[]; foreach($pcs as $piece){ if (array_key_exists($piece, $found)){ var_dump("tag already found: $piece"); continue; } $found[$piece]=true; } var_dump("found ".count($found)." tags");
Output for 7.2.29 - 7.2.33, 7.3.16 - 7.3.33, 7.4.4 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
string(22) "tag already found: sky" string(13) "found 29 tags"

preferences:
144.7 ms | 403 KiB | 131 Q