当前位置: 首页>>代码示例>>PHP>>正文


PHP Matrix::sort方法代码示例

本文整理汇总了PHP中Matrix::sort方法的典型用法代码示例。如果您正苦于以下问题:PHP Matrix::sort方法的具体用法?PHP Matrix::sort怎么用?PHP Matrix::sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Matrix的用法示例。


在下文中一共展示了Matrix::sort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: find

 /**
 		Return an array of objects matching criteria
 			@return array
 			@param $cond array
 			@param $seq array
 			@param $limit mixed
 			@param $ofs int
 			@param $jig boolean
 			@public
 	**/
 function find(array $cond = NULL, array $seq = NULL, $limit = 0, $ofs = 0, $jig = TRUE)
 {
     $table = $this->db->read($this->table);
     $result = array();
     if ($table) {
         if (is_array($seq)) {
             foreach (array_reverse($seq, TRUE) as $key => $sort) {
                 Matrix::sort($table, $key, $sort);
             }
         }
         foreach ($table as $key => $obj) {
             $obj['_id'] = $key;
             if (is_null($cond) || $this->check($cond, $obj)) {
                 $result[] = $jig ? $this->factory($obj) : $obj;
             }
         }
         $result = array_slice($result, $ofs, $limit ?: NULL);
     }
     $this->db->result = $result;
     return $result;
 }
开发者ID:groupdocs,项目名称:groupdocs-php,代码行数:31,代码来源:filedb.php

示例2: matrix

 function matrix()
 {
     $this->set('title', 'Matrix');
     $this->expect(is_null($this->get('ERROR')), 'No errors expected at this point', 'ERROR variable is set: ' . $this->get('ERROR.text'));
     $z = array(array('id' => 123, 'name' => 'paul', 'sales' => 0.35), array('id' => 456, 'name' => 'ringo', 'sales' => 0.13), array('id' => 345, 'name' => 'george', 'sales' => 0.57), array('id' => 234, 'name' => 'john', 'sales' => 0.79));
     Matrix::sort($z, 'name');
     $this->expect(array_values($z) == array(array('id' => 345, 'name' => 'george', 'sales' => 0.57), array('id' => 234, 'name' => 'john', 'sales' => 0.79), array('id' => 123, 'name' => 'paul', 'sales' => 0.35), array('id' => 456, 'name' => 'ringo', 'sales' => 0.13)), 'Sorting a multi-dimensional array by string column works properly', 'Incorrect array sort algorithm: ' . var_export($z, TRUE));
     Matrix::sort($z, 'id');
     $this->expect(array_values($z) == array(array('id' => 123, 'name' => 'paul', 'sales' => 0.35), array('id' => 234, 'name' => 'john', 'sales' => 0.79), array('id' => 345, 'name' => 'george', 'sales' => 0.57), array('id' => 456, 'name' => 'ringo', 'sales' => 0.13)), 'Sorting a multi-dimensional array by integer column works properly', 'Incorrect array sort algorithm: ' . var_export($z, TRUE));
     Matrix::sort($z, 'sales');
     $this->expect(array_values($z) == array(array('id' => 456, 'name' => 'ringo', 'sales' => 0.13), array('id' => 123, 'name' => 'paul', 'sales' => 0.35), array('id' => 345, 'name' => 'george', 'sales' => 0.57), array('id' => 234, 'name' => 'john', 'sales' => 0.79)), 'Sorting a multi-dimensional array by float column works properly', 'Incorrect array sort algorithm: ' . var_export($z, TRUE));
     echo $this->render('basic/results.htm');
 }
开发者ID:nian2go,项目名称:fatfree,代码行数:13,代码来源:main.php


注:本文中的Matrix::sort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。