3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tags = ' #portugal #sagres #cabodesaovicente #love #travel #couple #holiday #vacation #ig_europe #landmark #reflections #ocean #europe #sky #reflection #water #people #sea #pretty #fun #beach #house #village #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(13) "found 30 tags"

preferences:
117.51 ms | 403 KiB | 131 Q