note 101558 modified in function.sort by danbrown

From: Date: Fri, 06 Jan 2012 19:08:25 +0000
Subject: note 101558 modified in function.sort by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-185399@lists.php.net to get a copy of this message
sort from textfile by coloumn example name||date||time||comments if you want to sort by date $column = 2 <?php function array_sort($array,$column){ $column = $column-1; foreach($array as $line){ $bits = explode("||",$line); $bits ="$bits[$column]**$line"; $array1[]=$bits; } asort($array1); foreach($array1 as $line){ $bit = explode("**",$line); $bit ="$bit[1]"; $array2[]=$bit; } return$array2; } ?> --was-- sort from textfile by coloumn example name||date||time||comments if you want to sort by date $column = 2 <?php function array_sort($array,$column){ $column = $column-1; foreach($array as $line){ $bits = explode("||",$line); $bits ="$bits[$column]**$line"; $array1[]=$bits; } asort($array1); foreach($array1 as $line){ $bit = explode("**",$line); $bit ="$bit[1]"; $array2[]=$bit; } return$array2; } ?> www.toptenz.tk www.miyaru.co.tv http://php.net/manual/en/function.sort.php

« previous php.notes (#185399) next »