note 88922 deleted from function.in-array by sobak
| From: | sobak@php.net | Date: | Sat, 25 Feb 2017 06:05:51 +0000 |
| Subject: | note 88922 deleted from function.in-array by sobak | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-208845@lists.php.net to get a copy of this message | ||
Note Submitter: selmand [at] gmail.com
----
Removes same text with in_array in a string.
<?
$hizmet="aeg,akai,aeg,arcelik,aeg,arcelik,klima,kombi";
// alots of same stings
$x=explode(",",$hizmet);
$t= array();
$k=0;
for($i=0;$i<sizeof($x);$i++){ // this for remove its
//echo $x[$i]."\n";
if(!in_array($x[$i],$t))
{
$t[$k]=$x[$i];
$k++;
}
}
for($i=0;$i<sizeof($t);$i++){ // rebuilding $hizmet strings.
echo $t[$i].",";
}
?>