- array_map: documentation ( source)
- var_dump: documentation ( source)
- explode: documentation ( source)
<?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");