array_unique MOONLIGHT

The question was asked: 49 years 8 months ago   views: 4
0

Good time to all friends! code like this

$file = file_get_contents("alm.txt");//Refer to the text document with file_get_contents(); preg_match_all("/([^,]+)/i", $file,$matches);//Read everything in it except the comma and write each email in a separate cell of the array $matches $arr = $matches; $arr = array_unique($arr);//choose only unikalne cell values array print_r($arr); //check THEY STILL REPEAT

What's the matter?

Asked: 01-01-1970 в 03:00:00

Answers   1

0
$file = file_get_contents("alm.txt");//Refer to the text document with file_get_contents(); preg_match_all("/([^,]+)/i", $file,$matches);//Read everything in it except the comma and write each email in a separate cell of the array $matches $arr = $matches; $arr = array_unique($arr[0]);//Changed this line here var_dump($arr); //TA-DAAA ))) it worked! truth is, I never realized what was happening))))
Answered: 23-12-2012 в 15:52:02
ololo, though you differ from preg_match_all preg_match? :D - 23-12-2012 в 16:05:33
no I'm new to this thing)) tell me - 23-12-2012 в 16:07:22
make var_dump($arr) in both cases, and understand the difference :-) in short - preg_match affects one (included in reg. the expression string) and preg_match_all - all. For this and arrays is different. - 23-12-2012 в 16:10:05