Re: Distinct Items in an Array

From: Date: Thu, 17 Apr 2003 15:40:22 +0000
Subject: Re: Distinct Items in an Array
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-144313@lists.php.net to get a copy of this message
<?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 (#144313) next »