Hi im Trying to remove duplicate entries from a text file i load it will grab a string and display the array
also i asked it to save the array to a textfile
Problem is the text file has duplicates in and i cant get rid of them no matter what i do..
Im really stuck at this part i would love some help..
Here is my code
This is the out put of the code
Array
(
[0] => Array
(
[0] => 00000000-00000000-00000000-00000001
[1] => 00000000-00000000-00000000-0000000B
[2] => 00000000-00000000-00000000-0000000F
[3] => 00000000-00000000-00000000-00000016
[4] => 00000000-00000000-00000000-00010001
[74] => 00000000-00000000-00000000-00000001
[75] => 00000000-00000000-00000000-0000000B
[76] => 00000000-00000000-00000000-0000000F
[77] => 00000000-00000000-00000000-00000001
[78] => 00000000-00000000-00000000-0000000B
[79] => 00000000-00000000-00000000-0000000F
[80] => 00000000-00000000-00000000-00000016
As you can see its duplicating the value.
either to remove the key and kill duplicates that way or a method to just kill the duplicates..
Im really stuck
Any help would be amazing.
also i asked it to save the array to a textfile
Problem is the text file has duplicates in and i cant get rid of them no matter what i do..
Im really stuck at this part i would love some help..
Here is my code
Code:
<?
$loadfile = file_get_contents("codes.txt");
$expression = "#[A-Z0-9]{8}([-_][A-Z0-9]{8}){3}#";
$resultat = Array("#[A-Z0-9]{8}([-_][A-Z0-9]{8}){3}#");
$file="test.txt";
preg_match_all($expression, $loadfile, $resultat, PREG_PATTERN_ORDER);
echo "<pre>";
print_r(array_unique($resultat));
echo "</pre>";
ob_start();
print_r(array_unique($resultat));
$result = ob_get_contents();
ob_end_clean();
$handle=fopen($file, "w");
fwrite($handle, $result);
fclose($handle);
?>
This is the out put of the code
Array
(
[0] => Array
(
[0] => 00000000-00000000-00000000-00000001
[1] => 00000000-00000000-00000000-0000000B
[2] => 00000000-00000000-00000000-0000000F
[3] => 00000000-00000000-00000000-00000016
[4] => 00000000-00000000-00000000-00010001
[74] => 00000000-00000000-00000000-00000001
[75] => 00000000-00000000-00000000-0000000B
[76] => 00000000-00000000-00000000-0000000F
[77] => 00000000-00000000-00000000-00000001
[78] => 00000000-00000000-00000000-0000000B
[79] => 00000000-00000000-00000000-0000000F
[80] => 00000000-00000000-00000000-00000016
As you can see its duplicating the value.
either to remove the key and kill duplicates that way or a method to just kill the duplicates..
Im really stuck
Any help would be amazing.