Alicia Collins
Alicia Collins

Reputation: 33

annoying array tags.. want a pretty output

What i'm trying to do is make my output usable for a spreadsheet.

I want each item in the output without array tags or not mashed together but starting with an asterisk and ending with a % sign.

<?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); 
?>

Upvotes: 0

Views: 49

Answers (1)

matt
matt

Reputation: 1983

Maybe this would give you what you want:

$str = "*" . implode("% *", $no_duplicates) . "%";
echo '<pre>';
echo $str;
echo '</pre>';

Upvotes: 1

Related Questions