note 68306 added to function.sort

From: Date: Fri, 21 Jul 2006 17:31:05 +0000
Subject: note 68306 added to function.sort
Groups: php.notes 
Request: Send a blank email to php-notes+get-115017@lists.php.net to get a copy of this message
Here is how you would open a file, and put each line into an array. This sorts by the first field $title field. The next thing I would like to figure out is how to do this same sort but with the ability to skip the first word of the title. Like if the title has an "a" or "the" it would skip that portion of the sort. $currentfile = "file.txt"; $fp = fopen( $currentfile, "r" ) or die("Couldn't open $currentfile"); while ( ! feof( $fp ) ) { $line[] = fgets( $fp, 1024 ); foreach ( $line as $newarray ) { } $newline[] = trim($newarray); sort($newline); list($title1, $titleurl1, $rating1) = split ('\|', $newline[0]); list($title2, $titleurl2, $rating2) = split ('\|', $newline[1]); list($title3, $titleurl3, $rating3) = split ('\|', $newline[2]); list($title4, $titleurl4, $rating4) = split ('\|', $newline[3]); ---- Server IP: 64.71.164.2 Probable Submitter: 67.176.38.16 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.sort.php Edit -- http://master.php.net/note/edit/68306 Del: integrated -- http://master.php.net/note/delete/68306/integrated Del: useless -- http://master.php.net/note/delete/68306/useless Del: bad code -- http://master.php.net/note/delete/68306/bad+code Del: spam -- http://master.php.net/note/delete/68306/spam Del: non-english -- http://master.php.net/note/delete/68306/non-english Del: in docs -- http://master.php.net/note/delete/68306/in+docs Del: other reasons-- http://master.php.net/note/delete/68306 Reject -- http://master.php.net/note/reject/68306 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#115017) next »