samedi 26 octobre 2019

Remove duplicate from string

I beginner in php.

I have this code:

$string = '["Rumia","Rumia","Joarilla de las Matas","Rumia"]';

How can I remove duplicate from this string?

I build this string by this code:

$res = app('geocoder')->geocode($request->input('city'))->get();
foreach ($res as $value) {
if($formatter->format($value, '%L') !=""){
$string .= '"'.$formatter->format($value, '%L').'"'. ",";
}
}

if (strlen($string) > 0){
$string = mb_substr($string, 0, -1);
echo "[".$string."]";
}


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire