• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP sort函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get_token_from_guids

function get_token_from_guids($guids)
{
    $guids = array_unique($guids);
    sort($guids);
    $string = implode(',', $guids);
    return md5($string);
}
开发者ID:beck24,项目名称:granular_access,代码行数:7,代码来源:functions.php


示例2: getArrClasses

 /**
  * 
  * get array of slide classes, between two sections.
  */
 public function getArrClasses($startText = "", $endText = "", $explodeonspace = false)
 {
     $content = $this->cssContent;
     //trim from top
     if (!empty($startText)) {
         $posStart = strpos($content, $startText);
         if ($posStart !== false) {
             $content = substr($content, $posStart, strlen($content) - $posStart);
         }
     }
     //trim from bottom
     if (!empty($endText)) {
         $posEnd = strpos($content, $endText);
         if ($posEnd !== false) {
             $content = substr($content, 0, $posEnd);
         }
     }
     //get styles
     $lines = explode("\n", $content);
     $arrClasses = array();
     foreach ($lines as $key => $line) {
         $line = trim($line);
         if (strpos($line, "{") === false) {
             continue;
         }
         //skip unnessasary links
         if (strpos($line, ".caption a") !== false) {
             continue;
         }
         if (strpos($line, ".tp-caption a") !== false) {
             continue;
         }
         //get style out of the line
         $class = str_replace("{", "", $line);
         $class = trim($class);
         //skip captions like this: .tp-caption.imageclass img
         if (strpos($class, " ") !== false) {
             if (!$explodeonspace) {
                 continue;
             } else {
                 $class = explode(',', $class);
                 $class = $class[0];
             }
         }
         //skip captions like this: .tp-caption.imageclass:hover, :before, :after
         if (strpos($class, ":") !== false) {
             continue;
         }
         $class = str_replace(".caption.", ".", $class);
         $class = str_replace(".tp-caption.", ".", $class);
         $class = str_replace(".", "", $class);
         $class = trim($class);
         $arrWords = explode(" ", $class);
         $class = $arrWords[count($arrWords) - 1];
         $class = trim($class);
         $arrClasses[] = $class;
     }
     sort($arrClasses);
     return $arrClasses;
 }
开发者ID:robertmeans,项目名称:evergreentaphouse,代码行数:64,代码来源:cssparser.class.php


示例3: getFolderList

 /**
  * Image Manager Popup
  *
  * @param string $listFolder The image directory to display
  * @since 1.5
  */
 function getFolderList($base = null)
 {
     global $mainframe;
     // Get some paths from the request
     if (empty($base)) {
         $base = JA_WORKING_DATA_FOLDER;
     }
     // Get the list of folders
     jimport('joomla.filesystem.folder');
     $folders = JFolder::folders($base, '.', 4, true);
     // Load appropriate language files
     $lang =& JFactory::getLanguage();
     $lang->load(JRequest::getCmd('option'), JPATH_ADMINISTRATOR);
     $document =& JFactory::getDocument();
     $document->setTitle(JText::_('Insert Image'));
     // Build the array of select options for the folder list
     $options[] = JHTML::_('select.option', "", "/");
     foreach ($folders as $folder) {
         $folder = str_replace(JA_WORKING_DATA_FOLDER, "", $folder);
         $value = substr($folder, 1);
         $text = str_replace(DS, "/", $folder);
         $options[] = JHTML::_('select.option', $value, $text);
     }
     // Sort the folder list array
     if (is_array($options)) {
         sort($options);
     }
     // Create the drop-down folder select list
     $list = JHTML::_('select.genericlist', $options, 'folderlist', "class=\"inputbox\" size=\"1\" onchange=\"ImageManager.setFolder(this.options[this.selectedIndex].value)\" ", 'value', 'text', $base);
     return $list;
 }
开发者ID:rlee1962,项目名称:diylegalcenter,代码行数:37,代码来源:repo.php


示例4: listCommands

 private static function listCommands()
 {
     $commands = array();
     $dir = __DIR__;
     if ($handle = opendir($dir)) {
         while (false !== ($entry = readdir($handle))) {
             if ($entry != "." && $entry != ".." && $entry != "base.php") {
                 $s1 = explode("cli_", $entry);
                 $s2 = explode(".php", $s1[1]);
                 if (sizeof($s2) == 2) {
                     require_once "{$dir}/{$entry}";
                     $command = $s2[0];
                     $className = "cli_{$command}";
                     $class = new $className();
                     if (is_a($class, "cliCommand")) {
                         $commands[] = $command;
                     }
                 }
             }
         }
         closedir($handle);
     }
     sort($commands);
     return implode(" ", $commands);
 }
开发者ID:Covert-Inferno,项目名称:zKillboard,代码行数:25,代码来源:cli_help.php


示例5: getTableList

 /**
  * getTableList
  *
  * @return Array A list of tables based off the table schema that should be present in the system.
  */
 public function getTableList()
 {
     $tables = $this->getExpectedSchema();
     $tables = array_keys($tables);
     sort($tables);
     return $tables;
 }
开发者ID:hungnv0789,项目名称:vhtm,代码行数:12,代码来源:dbcheck.php


示例6: run

    /**
     * Execute the action.
     *
     * @param array command line parameters specific for this command
     */
    public function run($args)
    {
        $runner = $this->getCommandRunner();
        $commands = $runner->commands;
        if (isset($args[0])) {
            $name = strtolower($args[0]);
        }
        if (!isset($args[0]) || !isset($commands[$name])) {
            echo <<<EOD
At the prompt, you may enter a PHP statement or one of the following commands:

EOD;
            $commandNames = array_keys($commands);
            sort($commandNames);
            echo ' - ' . implode("\n - ", $commandNames);
            echo <<<EOD


Type 'help <command-name>' for details about a command.

To expand the above command list, place your command class files
under 'protected/commands/shell', or a directory specified
by the 'YIIC_SHELL_COMMAND_PATH' environment variable. The command class
must extend from CConsoleCommand.

EOD;
        } else {
            echo $runner->createCommand($name)->getHelp();
        }
    }
开发者ID:noxt,项目名称:business-keeper,代码行数:35,代码来源:HelpCommand.php


示例7: getAvailable

 /**
  * Gets a pipe-separated string of available languages
  *
  * @return string
  */
 public function getAvailable()
 {
     $languagesArray = $this->languages;
     //Make local copy
     sort($languagesArray);
     return implode('|', array_reverse($languagesArray));
 }
开发者ID:nickbalestra,项目名称:grav,代码行数:12,代码来源:Language.php


示例8: setup_files

 /**
  * Takes the included files and breaks up into mutli arrays for use in the debugger
  * @param array $files
  * @return Ambigous <multitype:unknown , unknown>
  */
 public function setup_files(array $files)
 {
     sort($files);
     $path_third = realpath(eedt_third_party_path());
     $path_ee = realpath(APPPATH);
     $path_first_modules = realpath(PATH_MOD);
     $bootstrap_file = FCPATH . SELF;
     $return = array();
     foreach ($files as $file) {
         if (strpos($file, $path_third) === 0) {
             $return['third_party_addon'][] = $file;
             continue;
         }
         if (strpos($file, $path_first_modules) === 0) {
             $return['first_party_modules'][] = $file;
             continue;
         }
         if (strpos($file, $bootstrap_file) === 0) {
             $return['bootstrap_file'] = $file;
             continue;
         }
         if (strpos($file, $path_ee) === 0) {
             $return['expressionengine_core'][] = $file;
             continue;
         }
         $return['other_files'][] = $file;
     }
     return $return;
 }
开发者ID:tobystokes,项目名称:ee_debug_toolbar,代码行数:34,代码来源:Toolbar.php


示例9: beforeFilter

 public function beforeFilter()
 {
     parent::beforeFilter();
     // Update current semester, if needed
     if (date('m') < 5) {
         // Winter semester
         $this->currentSemester = date('Y') . '01';
     } elseif (date('m') < 9) {
         // Summer semester
         $this->currentSemester = date('Y') . '05';
     } else {
         // Autumn semester
         $this->currentSemester = date('Y') . '09';
     }
     if ($this->Session->read('Registration.semester') != '') {
         $this->registrationSemester = $this->Session->read('Registration.semester');
     } else {
         $this->registrationSemester = '201501';
         $this->Session->write('Registration.semester', $this->registrationSemester);
     }
     // If unregistration is still possible for current semester, add it to the registration semesters list
     if (!in_array($this->currentSemester, $this->registrationSemesters) && $this->deadlines[$this->currentSemester]['drop_fee'] >= date('Ymd')) {
         $this->registrationSemesters[] = $this->currentSemester;
         sort($this->registrationSemesters);
     }
 }
开发者ID:julienasp,项目名称:Pilule,代码行数:26,代码来源:RegistrationController.php


示例10: testMode

 /**
  * @dataProvider dataProviderForMode
  */
 public function testMode(array $numbers, $modes)
 {
     $computed_modes = Average::mode($numbers);
     sort($modes);
     sort($computed_modes);
     $this->assertEquals($modes, $computed_modes);
 }
开发者ID:markrogoyski,项目名称:math-php,代码行数:10,代码来源:AverageTest.php


示例11: display_array_content_style

 function display_array_content_style($arrayname, $method, $base_url)
 {
     $a = "";
     sort($arrayname);
     while (list($key, $value) = each($arrayname)) {
         if (is_array($value)) {
             $c = display_array_content($value, '');
             $d = ltrim($c, "0");
             $d = str_replace("-", "", $c);
             $a .= "<a id='modal_window_link' href='" . $base_url . "output/print.output.php?section=styles&amp;view=" . $c . "&amp;tb=true'>" . $d . "</a>";
         } else {
             $e = ltrim($value, "0");
             $e = str_replace("-", "", $value);
             $a .= "<a id='modal_window_link' href='" . $base_url . "output/print.output.php?section=styles&amp;view=" . $value . "&amp;tb=true'>" . $e . "</a>";
         }
         if ($method == "1") {
             $a .= "";
         }
         if ($method == "2") {
             $a .= "&nbsp;&nbsp;";
         }
         if ($method == "3") {
             $a .= ", ";
         }
     }
     $b = rtrim($a, "&nbsp;&nbsp;");
     $b = rtrim($b, "  ");
     return $b;
 }
开发者ID:anigeluk,项目名称:brewcompetitiononlineentry,代码行数:29,代码来源:brew.sec.php


示例12: execute

 public function execute(PhutilArgumentParser $args)
 {
     $can_recover = id(new PhabricatorPeopleQuery())->setViewer($this->getViewer())->withIsAdmin(true)->execute();
     if (!$can_recover) {
         throw new PhutilArgumentUsageException(pht('This Phabricator installation has no recoverable administrator ' . 'accounts. You can use `bin/accountadmin` to create a new ' . 'administrator account or make an existing user an administrator.'));
     }
     $can_recover = mpull($can_recover, 'getUsername');
     sort($can_recover);
     $can_recover = implode(', ', $can_recover);
     $usernames = $args->getArg('username');
     if (!$usernames) {
         throw new PhutilArgumentUsageException(pht('You must specify the username of the account to recover.'));
     } else {
         if (count($usernames) > 1) {
             throw new PhutilArgumentUsageException(pht('You can only recover the username for one account.'));
         }
     }
     $username = head($usernames);
     $user = id(new PhabricatorPeopleQuery())->setViewer($this->getViewer())->withUsernames(array($username))->executeOne();
     if (!$user) {
         throw new PhutilArgumentUsageException(pht('No such user "%s". Recoverable administrator accounts are: %s.', $username, $can_recover));
     }
     if (!$user->getIsAdmin()) {
         throw new PhutilArgumentUsageException(pht('You can only recover administrator accounts, but %s is not an ' . 'administrator. Recoverable administrator accounts are: %s.', $username, $can_recover));
     }
     $engine = new PhabricatorAuthSessionEngine();
     $onetime_uri = $engine->getOneTimeLoginURI($user, null, PhabricatorAuthSessionEngine::ONETIME_RECOVER);
     $console = PhutilConsole::getConsole();
     $console->writeOut(pht('Use this link to recover access to the "%s" account from the web ' . 'interface:', $username));
     $console->writeOut("\n\n");
     $console->writeOut('    %s', $onetime_uri);
     $console->writeOut("\n\n");
     $console->writeOut(pht('After logging in, you can use the "Auth" application to add or ' . 'restore authentication providers and allow normal logins to ' . 'succeed.') . "\n");
     return 0;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:35,代码来源:PhabricatorAuthManagementRecoverWorkflow.php


示例13: signRequest

 public function signRequest(RequestInterface $request, CredentialsInterface $credentials)
 {
     // Ensure that the signable query string parameters are sorted
     sort($this->signableQueryString);
     // Add the security token header if one is being used by the credentials
     if ($token = $credentials->getSecurityToken()) {
         $request->setHeader('x-amz-security-token', $token);
     }
     $request->removeHeader('x-amz-date');
     $request->setHeader('Date', gmdate(\DateTime::RFC2822));
     $stringToSign = $this->createCanonicalizedString($request);
     $request->getParams()->set('aws.string_to_sign', $stringToSign);
     $request->setHeader('Authorization', 'AWS ' . $credentials->getAccessKeyId() . ':' . $this->signString($stringToSign, $credentials));
     //         COMMONLOG(DEBUG, "send header:%s",$request->getRawHeaders());
     //         if(self::$isFile)
     //         {
     //         	if(self::$filePath)
     //         		COMMONLOG(DEBUG, "souce file:%s",self::$filePath);
     //         }
     //         else
     //        {
     //        		if(get_class($request) === 'Guzzle\Http\Message\EntityEnclosingRequest' && get_class($request->getBody()) === 'Guzzle\Http\EntityBody' &&  $request->getBody()->getContentLength() != 0)
     //        		{
     //        			COMMONLOG(DEBUG, "send msg:%s",$request->getBody());
     //        		}
     //         }
 }
开发者ID:eSDK,项目名称:esdk_obs_native_php,代码行数:27,代码来源:S3Signature.php


示例14: get_data

 private function get_data()
 {
     $this->ci->db->join('rm r', 'r.mid = m.mid');
     $this->ci->db->join('url u', 'u.rid = r.rid');
     $query = $this->ci->db->get_where('mn m', ['u.uid' => $this->id, 'm.mstat' => TRUE]);
     $result = $query->result_array();
     if (!empty($result)) {
         $data = [];
         $tmp = [];
         foreach ($result as $val) {
             $mpar = $val['mpar'] == 1 ? 0 : $val['mpar'];
             $tmp[$val['mid']][] = json_decode_db($val['rmk']);
             $data[$val['mid']] = ['mid' => $val['mid'], 'mpar' => $mpar, 'mnme' => $val['mnme'], 'mico' => $val['mico'], 'mlnk' => $val['mlnk']];
         }
         $array_key = [];
         foreach ($tmp as $k => $v) {
             $array_key[$k] = [];
             foreach ($v as $vv) {
                 if (is_array($vv) == FALSE) {
                     continue;
                 }
                 $array_key[$k] = array_merge($array_key[$k], $vv);
             }
             $array_key[$k] = array_unique($array_key[$k]);
             sort($array_key[$k]);
         }
         foreach ($data as $kk => $vvv) {
             $data[$kk]['key'] = $array_key[$kk];
         }
     }
     return isset($data) ? $data : [];
 }
开发者ID:soniibrol,项目名称:package,代码行数:32,代码来源:Sso.php


示例15: test_nonunique_postmeta

 function test_nonunique_postmeta()
 {
     // Add two non unique post meta item
     $this->assertInternalType('integer', add_post_meta($this->post_id, 'nonunique', 'value'));
     $this->assertInternalType('integer', add_post_meta($this->post_id, 'nonunique', 'another value'));
     //Check they exists
     $this->assertEquals('value', get_post_meta($this->post_id, 'nonunique', true));
     $this->assertEquals(array('value', 'another value'), get_post_meta($this->post_id, 'nonunique', false));
     //Fail to delete the wrong value
     $this->assertFalse(delete_post_meta($this->post_id, 'nonunique', 'wrong value'));
     //Delete the first one
     $this->assertTrue(delete_post_meta($this->post_id, 'nonunique', 'value'));
     //Check the remainder exists
     $this->assertEquals('another value', get_post_meta($this->post_id, 'nonunique', true));
     $this->assertEquals(array('another value'), get_post_meta($this->post_id, 'nonunique', false));
     //Add a third one
     $this->assertInternalType('integer', add_post_meta($this->post_id, 'nonunique', 'someother value'));
     //Check they exists
     $expected = array('someother value', 'another value');
     sort($expected);
     $this->assertTrue(in_array(get_post_meta($this->post_id, 'nonunique', true), $expected));
     $actual = get_post_meta($this->post_id, 'nonunique', false);
     sort($actual);
     $this->assertEquals($expected, $actual);
     //Delete the lot
     $this->assertTrue(delete_post_meta_by_key('nonunique'));
 }
开发者ID:boonebgorges,项目名称:wp,代码行数:27,代码来源:meta.php


示例16: visitTagNode

 /**
  * @inheritdoc
  */
 public function visitTagNode($tag, $definition)
 {
     // If the tag is not closed or if nest limit is not set then continue with the children
     if ($tag->getClosed() !== TagNode::CLOSED || is_null($definition->nestLimit)) {
         foreach ($tag->getChildren() as $child) {
             $child->accept($this);
         }
         return;
     }
     // Visitor applies. Retrieve the proper tagName to check against
     if (isset($definition->nestGroup)) {
         sort($definition->nestGroup);
         $tagName = implode(':', $definition->nestGroup);
     } else {
         $tagName = $definition->tag;
     }
     // Increment current tag count
     $this->tagList[$tagName] = ($this->tagList[$tagName] ?? 0) + 1;
     // Check for over-nesting
     if ($this->tagList[$tagName] > $definition->nestLimit) {
         $this->engine->addError($tagName, '[' . $tagName . '] cannot be nested more than ' . $definition->nestLimit . ' times.');
         $tag->setClosed(TagNode::PARTIAL);
     }
     // Check the children
     foreach ($tag->getChildren() as $child) {
         $child->accept($this);
     }
     // Decrement current tag number
     --$this->tagList[$tagName];
 }
开发者ID:ncgamers,项目名称:qikbb,代码行数:33,代码来源:NestLimitVisitor.php


示例17: fetch

 public function fetch()
 {
     // Обработка действий
     if ($this->request->method('post')) {
         // Действия с выбранными
         $ids = $this->request->post('check');
         if (is_array($ids)) {
             switch ($this->request->post('action')) {
                 case 'delete':
                     foreach ($ids as $id) {
                         $this->brands->delete_brand($id);
                     }
                     break;
             }
         }
         // Сортировка
         $positions = $this->request->post('positions');
         $ids = array_keys($positions);
         sort($positions);
         foreach ($positions as $i => $position) {
             $this->brands->update_brand($ids[$i], array('position' => $position));
         }
     }
     $brands = $this->brands->get_brands();
     $this->design->assign('brands', $brands);
     return $this->body = $this->design->fetch('brands.tpl');
 }
开发者ID:OkayCMS,项目名称:Okay,代码行数:27,代码来源:BrandsAdmin.php


示例18: render

 /**
  * @inheritdoc
  */
 public function render($context, $targetDir)
 {
     parent::render($context, $targetDir);
     if ($this->controller !== null) {
         $this->controller->stdout("writing packages file...");
     }
     $packages = [];
     $notNamespaced = [];
     foreach (array_merge($context->classes, $context->interfaces, $context->traits) as $type) {
         /* @var $type TypeDoc */
         if (empty($type->namespace)) {
             $notNamespaced[] = str_replace('\\', '-', $type->name);
         } else {
             $packages[$type->namespace][] = str_replace('\\', '-', $type->name);
         }
     }
     ksort($packages);
     $packages = array_merge(['Not namespaced' => $notNamespaced], $packages);
     foreach ($packages as $name => $classes) {
         sort($packages[$name]);
     }
     file_put_contents($targetDir . '/packages.txt', serialize($packages));
     if ($this->controller !== null) {
         $this->controller->stdout('done.' . PHP_EOL, Console::FG_GREEN);
     }
 }
开发者ID:136216444,项目名称:yii2-apidoc,代码行数:29,代码来源:ApiRenderer.php


示例19: getHTML

 public function getHTML()
 {
     wfProfileIn(__METHOD__);
     $this->report->loadSources();
     $aData = array();
     $aLabel = array();
     if (count($this->report->reportSources) == 0) {
         return '';
     }
     foreach ($this->report->reportSources as $reportSource) {
         $reportSource->getData();
         $this->actualDate = $reportSource->actualDate;
         if (!empty($reportSource->dataAll) && !empty($reportSource->dataTitles)) {
             if (is_array($reportSource->dataAll)) {
                 foreach ($reportSource->dataAll as $key => $val) {
                     if (isset($aData[$key])) {
                         $aData[$key] = array_merge($aData[$key], $val);
                     } else {
                         $aData[$key] = $val;
                     }
                 }
             }
             $aLabel += $reportSource->dataTitles;
         }
     }
     sort($aData);
     $this->sourceData = array_reverse($aData);
     $this->sourceLabels = array_reverse($aLabel);
     $oTmpl = F::build('EasyTemplate', array(dirname(__FILE__) . "/templates/"));
     /** @var $oTmpl EasyTemplate */
     $oTmpl->set_vars(array('data' => $this->sourceData, 'labels' => $this->sourceLabels));
     wfProfileOut(__METHOD__);
     $this->beforePrint();
     return $oTmpl->render('../../templates/output/' . self::TEMPLATE_MAIN);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:35,代码来源:SDOutputCSV.class.php


示例20: run

 /**
  * Execute the action.
  * @param array $args command line parameters specific for this command
  * @return integer non zero application exit code after printing help
  */
 public function run($args)
 {
     $runner = $this->getCommandRunner();
     $commands = $runner->commands;
     if (isset($args[0])) {
         $name = strtolower($args[0]);
     }
     if (!isset($args[0]) || !isset($commands[$name])) {
         if (!empty($commands)) {
             echo "Yii command runner (based on Yii v" . Yii::getVersion() . ")\n";
             echo "Usage: " . $runner->getScriptName() . " <command-name> [parameters...]\n";
             echo "\nThe following commands are available:\n";
             $commandNames = array_keys($commands);
             sort($commandNames);
             echo ' - ' . implode("\n - ", $commandNames);
             echo "\n\nTo see individual command help, use the following:\n";
             echo "   " . $runner->getScriptName() . " help <command-name>\n";
         } else {
             echo "No available commands.\n";
             echo "Please define them under the following directory:\n";
             echo "\t" . Yii::app()->getCommandPath() . "\n";
         }
     } else {
         echo $runner->createCommand($name)->getHelp();
     }
     return 1;
 }
开发者ID:upmunspel,项目名称:abiturient,代码行数:32,代码来源:CHelpCommand.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP sortAppointments函数代码示例发布时间:2022-05-23
下一篇:
PHP sornot函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap