How to delete duplicates in php array ?
by THavamani[ Edit ] 2013-05-04 15:24:28
Try it..
<?php
$array = array('1','1','2','3');
foreach($array as $data){
$key= array_keys($array,$data);
if(count($key)>1){
foreach($key as $key2 => $data2){
unset($array[$key2]);
}
}
}
$array=array_values($array);
print_r($array);
?>
Input:
$array = array('1','1','2','3');
Output:
$array = array('2','3');
Guna
Why dont you use array_unique()?
0
0
Add Replypinnureenga boss. nangallem ennekku thozhila kaththukka poromo.
0
0
Add ReplyGuna
ithu ulagamaha nadipuda saami...
0
0
Add Reply