Hi there,
I’ll get right to it. Let’s say my data file contains the following:
[code=php]
—START DATA FILE—
|~~|20060228225218|~~|February 28, 2006 – 10:52 PM|~~|Fred|~~|Smith|~~|123 Abc Street|~~|Banora Point|~~|NSW|~~|4211|~~|
|~~|20060228225309|~~|February 28, 2006 – 10:53 PM|~~|Sally|~~|Citizen|~~|456 Def Street|~~|Nerang|~~|QLD|~~|2486|~~|
|~~|20060228225531|~~|February 28, 2006 – 10:55 PM|~~|Joe|~~|Bloe|~~|555 Evergreen Tce|~~|Springfield|~~|California|~~|12345|~~|
—END DATA FILE—
So far I have managed to get my script to write the elements from each row into a nice neat list using the code below (unecessary bits taken out). What I would like to be able to do is sort my entries alphabetically by $row[3] (the fourth element in each record). Can someone show me how to do this? I have tried many variations but with no luck! Any help is very much appreciated!
Regards,
Chris
[code=php]
$record = file($data_file);
rsort($record);
$jmlrec = count($record);
$jml_page = intval($jmlrec/$max_entry_per_page);
$sisa = $jmlrec%$max_entry_per_page;
if ($sisa > 0) $jml_page++;
$no = $page*$max_entry_per_page-$max_entry_per_page;
// This is the default message when there are no records posted – Chris
if ($jmlrec == 0) echo “<TR><TD colspan=3 bgcolor=’#FFE1E1′ align=’center’><FONT SIZE=’3′ FACE=’$font_face’>There are no address book entries listed at this present time.</FONT></TD></TR>”;
$w = 0; //– Alternating color values
for ($i=0; $i<$max_entry_per_page; $i++) {
$no++;
$recno = $no-1;
if (isset($record[$recno])) {
$row = explode(“|~~|”,$record[$recno]);
echo “<p>Here’s where I insert elements from my array:<br>
Element1: $row[0]<br>
Element2: $row[1]<br>
Element3: $row[2]<br>
Element4: $row[3]<br>
Element5: $row[4]<br>
etc, etc , etc</p>”;