我想做的是让我的输出可用于电子表格。
我希望输出中的每个项目都没有数组标签或不混合在一起,而是以星号开头并以 % 符号结尾。
<?php
$file = file_get_contents('aaa.txt'); //get file to string
$row_array = explode("'n",$file); //cut string to rows by new line
$row_array = array_count_values(array_filter($row_array));
foreach ($row_array as $key=>$counts) {
if ($counts==1)
$no_duplicates[] = $key;
}
//do what You want
echo '<pre>';
print_r($no_duplicates);
//write to file. If file don't exist. Create it
file_put_contents('no_duplicates.txt',$no_duplicates);
?>
也许这会给你你想要的:
$str = "*" . implode("% *", $no_duplicates) . "%";
echo '<pre>';
echo $str;
echo '</pre>';