note 50766 added to function.list
| From: | venkatesh at lammersmedical dot com | Date: | Wed, 09 Mar 2005 10:49:07 +0000 |
| Subject: | note 50766 added to function.list | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-86150@lists.php.net to get a copy of this message | ||
////////////////////////////////////////////////////////
// pp_CreateSortedList($database,$colname)
//
// Synopsis:
//
// L:69 Row length=((total number of elements in the databse-column count)/coulmn count)
// L:73 Getting nameline from the database
// L:77 Builds a list table ($NameLine) from a database table
// and finds the key of corresponding column name for
// sorting the given $database by it's coulmn name
// (call by reference)
// L:94 Property line invocation
// L:98 Reverse sorting
// Inputs:
// $database : List table of data
// $colname : column name of the $database
// $sort_typ : It referece the the type of sorting accarding to the requirement
//
// Returns:
// Sorted database table by it's coulmn name
//
// Error handling:
// -none (not yet)-
////////////////////////////////////////////////////////
//calculation of the length of the row in the database
function pp_CreateSortedList(&$database,$colname=null,$sort_typ=null){
$NameLine=array();
$Total=count($database,COUNT_RECURSIVE);
$column_count;
$column_count=count($database);
if($column_count<=1){
$row_Length=1;
}
else{
$row_Length=(($Total-$column_count)/$column_count);
}
for($i=0;$i<$row_Length;$i++)
{
$j=0;
array_push($NameLine,$database[$j][$i]);
}
$find_key=0;
while ($column_name = current($NameLine)){
if ($column_name == $colname){
$find_key = key($NameLine);
}
next($NameLine);
}
// echo "\r";
$tmplist = array();
$refer=array();
$idx = 0;
foreach($database as $cl){
if ($idx == 0){
$NameLine = $cl;
}
else{
$tmplist[$idx-1] = pp_CreatePropLine($NameLine, $cl);
}
$idx++;
}
if($colname!=null){
if($sort_typ=='REV'){
rsort($tmplist,$find_key);
}
foreach ($tmplist as $key => $row) {
$ReferenceCol[$key] = $row[$colname];
}
array_multisort($ReferenceCol,SORT_DESC,$tmplist);
}
return($tmplist);
}
----
Manual Page -- http://www.php.net/manual/en/function.list.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50766
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50766&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50766&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50766&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50766&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50766&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50766&report=yes
Search -- http://master.php.net/manage/user-notes.php