1zeus1 Posted July 28, 2015 Share Posted July 28, 2015 How can I delete duplicate in $data? $data = array(); foreach ($get->find('h3[class=r] a') as $e) { //---// $data[] = "$var1,$var2"; } $file = "/var/www/html/top; $Handle = fopen($file, 'a') or die("Unable to open file!"); fwrite($Handle, implode("\n", $data)); fclose($Handle); I tried this, but it does not work $data = array(); foreach ($get->find('h3[class=r] a') as $e) { //---// $data[] = array_unique($var1,$var2); } $file = "/var/www/html/top; $Handle = fopen($file, 'a') or die("Unable to open file!"); fwrite($Handle, implode("\n", $data)); fclose($Handle); Regards. Link to comment https://forums.phpfreaks.com/topic/297520-delete-duplicate/ Share on other sites More sharing options...
Barand Posted July 28, 2015 Share Posted July 28, 2015 It's time to rtfm http://uk1.php.net/manual/en/function.array-unique.php Link to comment https://forums.phpfreaks.com/topic/297520-delete-duplicate/#findComment-1517557 Share on other sites More sharing options...
1zeus1 Posted July 28, 2015 Author Share Posted July 28, 2015 I can not, to make this code Someone can help me Regards Link to comment https://forums.phpfreaks.com/topic/297520-delete-duplicate/#findComment-1517572 Share on other sites More sharing options...
Ch0cu3r Posted July 28, 2015 Share Posted July 28, 2015 You pass your array $data to array_unique not the values you are adding to the array. Link to comment https://forums.phpfreaks.com/topic/297520-delete-duplicate/#findComment-1517575 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.