Re: Distinct Items in an Array

From: Date: Thu, 17 Apr 2003 16:10:09 +0000
Subject: Re: Distinct Items in an Array
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-144320@lists.php.net to get a copy of this message
Ok I got it to work and I got the same result as my original problem. There were 9 "Feb" in the file. It printed out 8 "Null" and then "Feb". So the output was reversed of what I wanted. I want it to print out "Feb" and then 8 "Null" "Peter Pistorius" <peterp@podbox.co.za> wrote in message news:20030417154428.58178.qmail@pb1.pair.com... > <?php > > $fp = fopen('./file.txt', 'r'); > $temp_array = null; > > while (!feof($fp)) > { > $data = fgets($fp,4096); > $data = explode(',', $data); > $date = explode('-', $data[0]); > $temp_array["$date[1]"] += 1; > } > > fclose($fp); > > > foreach ($temp_array AS $key=>$value) { > > echo "$key -> $value <br />"; > > # $key is numeric value of month, $value is the amount of occurances in > the file. > > > $store_array[] = "$key"; > > for ($i = 1; $i < $value; $i++) { > > array_push($store_array, null); > > } > > } > > print_r($store_array); > > ?> > >

« previous php.general (#144320) next »