本文整理汇总了PHP中strnatcasecmp函数的典型用法代码示例。如果您正苦于以下问题:PHP strnatcasecmp函数的具体用法?PHP strnatcasecmp怎么用?PHP strnatcasecmp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了strnatcasecmp函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getList
/**
* Get a list of twitter-nicks ordered by groups
*
* @return mixed|void
*/
public function getList()
{
$twitter = $this->getEntityManager()->getRepository('Phpug\\Entity\\Service')->findBy(array('name' => 'Twitter'));
$twitters = $this->getEntityManager()->getRepository('Phpug\\Entity\\Groupcontact')->findBy(array('service' => $twitter[0]->id));
$twitterService = $this->getServiceLocator()->get('TwitterInfoService');
$result = array();
foreach ($twitters as $twitter) {
$group = $twitter->getGroup();
if (!$group) {
continue;
}
if (!$group instanceof Usergroup) {
continue;
}
if ($group->getState() != Usergroup::ACTIVE) {
continue;
}
if (!isset($result[$twitter->getName()])) {
$result[$twitter->getName()] = array('screen_name' => $twitter->getName(), 'name' => $twitterService->getInfoForUser('name', $twitter->getName()), 'url' => $twitter->getUrl(), 'icon_url' => $twitterService->getInfoForUser('profile_image_url_https', $twitter->getName()), 'groups' => array());
}
$groupMapUrl = $this->url()->fromRoute('home', array(), array('force_canonical' => true)) . '?center=' . $group->getShortName();
$groupApiUrl = $this->url()->fromRoute('api/rest', array('controller' => 'Usergroup', 'id' => $group->getId()), array('force_canonical' => true));
$result[$twitter->getName()]['groups'][] = array('usergroup' => $group->getName(), 'usergroup_url' => $group->getUrl(), 'phpug_group_map_url' => $groupMapUrl, 'phpug_group_api_url' => $groupApiUrl);
}
usort($result, function ($a, $b) {
return strnatcasecmp($a['name'], $b['name']);
});
$adapter = $this->getAdapter();
$response = $this->getResponse();
$response->setContent($adapter->serialize(array_values($result)));
return $response;
}
开发者ID:brainexe,项目名称:php.ug,代码行数:37,代码来源:TwitterController.php
示例2: Global_Init
function Global_Init()
{
//session_start();
Load_Configs();
if (!strnatcasecmp(trim($GLOBALS['db']['type']), "LB")) {
require_once 'inc/dbmodule_LB.php';
}
if (!strnatcasecmp(trim($GLOBALS['db']['type']), "GD")) {
require_once 'inc/dbmodule_GD.php';
}
//echo "GLOBALS: <BR>"; print_r($GLOBALS['db']); echo "<BR>";
$source_db_ok = SQL_DB_OK("source");
if ($source_db_ok['error'] === false) {
$GLOBALS['db']['s_resource'] = @mysql_connect($GLOBALS['db']['s_host'], $GLOBALS['db']['s_user'], $GLOBALS['db']['s_pass']) or die($_SERVER["SCRIPT_FILENAME"] . "Could not connect to Source MySQL Server. : " . mysql_error());
@mysql_selectdb($GLOBALS['db']['s_base']) or die("Could not connect to Source database [" . $GLOBALS['db']['s_base'] . "] : " . mysql_error());
$GLOBALS['db']['x_resource'] = @mysql_connect($GLOBALS['db']['x_host'], $GLOBALS['db']['x_user'], $GLOBALS['db']['x_pass']) or die($_SERVER["SCRIPT_FILENAME"] . "Could not connect to X-Ray MySQL Server. : " . mysql_error());
@mysql_selectdb($GLOBALS['db']['x_base']) or die("Could not connect to X-Ray database [" . $GLOBALS['db']['x_base'] . "] : " . mysql_error());
$GLOBALS['db']['s_link'] = mysqli_connect($GLOBALS['db']['s_host'], $GLOBALS['db']['s_user'], $GLOBALS['db']['s_pass'], $GLOBALS['db']['s_base']) or die($_SERVER["SCRIPT_FILENAME"] . "Could not connect to Source MySQL Server (multilink). : " . mysqli_error($GLOBALS['db']['s_link']));
mysqli_select_db($GLOBALS['db']['s_link'], $GLOBALS['db']['s_base']) or die("Could not connect to Source database (multilink) [" . $GLOBALS['db']['s_base'] . "] : " . mysqli_error($GLOBALS['db']['s_link']));
$GLOBALS['db']['x_link'] = mysqli_connect($GLOBALS['db']['x_host'], $GLOBALS['db']['x_user'], $GLOBALS['db']['x_pass'], $GLOBALS['db']['x_base']) or die($_SERVER["SCRIPT_FILENAME"] . "Could not connect to X-Ray MySQL Server (multilink). : " . mysqli_error($GLOBALS['db']['x_link']));
mysqli_select_db($GLOBALS['db']['x_link'], $GLOBALS['db']['x_base']) or die("Could not connect to X-Ray database (multilink) [" . $GLOBALS['db']['x_base'] . "] : " . mysqli_error($GLOBALS['db']['x_link']));
} else {
$config_error .= $source_db_ok['message'] . "<BR>";
}
// array_key_exists('form', $_POST) && $_POST['form']!="" ? $_GET = $_POST : NULL;
// array_key_exists('force', $_GET) && $_GET['force']!="" ? $_POST = $_GET : NULL;
if (count($_GET) > 0) {
$_POST = $_GET;
}
// if($_POST['form']!=""){$_GET = $_POST;}
// if($_GET['force']!=""){$_POST = $_GET;}
if (!FixOutput_Bool($GLOBALS['config_settings']['settings']['first_setup'], true, false, true)) {
$GLOBALS['worlds'] = Get_Worlds_Enabled();
}
}
开发者ID:babbottscott,项目名称:X-Ray-Detective,代码行数:35,代码来源:core_xdetector.php
示例3: recursiveFileListSortingHelper
/**
* This is a helper method that can be used with u?sort methods to sort a list of (relative) file paths, e.g.
* array("someDir/fileA", "fileA", "fileB", "anotherDir/fileA").
*
* Directories are sorted first in the lists, with the deepest structures first (while every level is sorted
* alphabetically)
*
* @param string $elementA
* @param string $elementB
* @return int
*/
public static function recursiveFileListSortingHelper($elementA, $elementB)
{
if (strpos($elementA, '/') === FALSE) {
// first element is a file
if (strpos($elementB, '/') === FALSE) {
$result = strnatcasecmp($elementA, $elementB);
} else {
// second element is a directory => always sort it first
$result = 1;
}
} else {
// first element is a directory
if (strpos($elementB, '/') === FALSE) {
// second element is a file => always sort it last
$result = -1;
} else {
// both elements are directories => we have to recursively sort here
list($pathPartA, $elementA) = explode('/', $elementA, 2);
list($pathPartB, $elementB) = explode('/', $elementB, 2);
if ($pathPartA === $pathPartB) {
// same directory => sort by subpaths
$result = self::recursiveFileListSortingHelper($elementA, $elementB);
} else {
// different directories => sort by current directories
$result = strnatcasecmp($pathPartA, $pathPartB);
}
}
}
return $result;
}
开发者ID:Mr-Robota,项目名称:TYPO3.CMS,代码行数:41,代码来源:ResourceUtility.php
示例4: compare_rows
function compare_rows($a, $b)
{
if (-1 == $this->column) {
return 0;
}
return strnatcasecmp($a[$this->column], $b[$this->column]);
}
开发者ID:vsalx,项目名称:rattieinfo,代码行数:7,代码来源:arraysort.class.php
示例5: sort
public static function sort(&$entries, $sortType)
{
switch ($sortType) {
case self::Title:
$cb = function ($a, $b) {
return strnatcasecmp($a->title, $b->title);
};
break;
case self::Score:
$cb = function ($a, $b) {
return $a->score < $b->score ? 1 : -1;
};
break;
case self::MeanScore:
$cb = function ($a, $b) {
return $a->meanScore < $b->meanScore ? 1 : -1;
};
break;
case self::MediaMalId:
$cb = function ($a, $b) {
return strcmp(sprintf('%s%05d', $a->media, $a->mal_id), sprintf('%s%05d', $b->media, $b->mal_id));
};
break;
default:
throw new RuntimeException('Bad sort type');
}
usort($entries, $cb);
}
开发者ID:Lucas8x,项目名称:graph,代码行数:28,代码来源:DataSorter.php
示例6: CableIDTabHandler
function CableIDTabHandler()
{
echo '<div class=portlet><h2>Cable ID Helper</h2></div>';
$rack = spotEntity('rack', $_REQUEST['rack_id']);
$result = usePreparedSelectBlade('SELECT DISTINCT object_id FROM RackSpace WHERE rack_id = ? ', array($rack['id']));
$objects = $result->fetchAll(PDO::FETCH_ASSOC);
$cableIDs = array();
foreach ($objects as $object) {
$pals = getObjectPortsAndLinks($object['object_id']);
foreach ($pals as $portLink) {
if ($portLink['cableid']) {
$new = true;
$dublicate = false;
foreach ($cableIDs as $key => $cableID) {
if ($portLink['object_id'] == $cableID['object1_id'] && $portLink['name'] == $cableID['object1_port'] || $portLink['object_id'] == $cableID['object2_id'] && $portLink['name'] == $cableID['object2_port']) {
$new = false;
// Link already in List
}
// Check for duplicate cable ids
if ($new && $portLink['cableid'] == $cableID['cableID']) {
$dublicate = true;
$cableIDs[$key]['dublicate'] = true;
}
}
if ($new) {
$cableID = array();
$cableID['cableID'] = $portLink['cableid'];
$cableID['object1_id'] = $portLink['object_id'];
$cableID['object1_name'] = $portLink['object_name'];
$cableID['object1_port'] = $portLink['name'];
$cableID['object2_id'] = $portLink['remote_object_id'];
$cableID['object2_name'] = $portLink['remote_object_name'];
$cableID['object2_port'] = $portLink['remote_name'];
$cableID['dublicate'] = $dublicate;
array_push($cableIDs, $cableID);
}
}
}
}
// Sort by cableIDs
usort($cableIDs, function ($elem1, $elem2) {
return strnatcasecmp($elem1['cableID'], $elem2['cableID']);
});
// Print table
echo '<table class="cooltable" align="center" border="0" cellpadding="5" cellspacing="0">' . '<tbody>' . ' <tr>' . ' <th>CableID</th>' . ' <th>Object 1</th>' . ' <th>Object 2</th>' . ' </tr>';
$i = 0;
foreach ($cableIDs as $cableID) {
if ($i % 2) {
$class = 'row_even tdleft';
} else {
$class = 'row_odd tdleft';
}
if ($cableID['dublicate']) {
$class .= ' trerror';
}
echo '<tr class="' . $class . '">' . '<td>' . $cableID['cableID'] . '</td>' . '<td><a href="' . makeHref(array('page' => 'object', 'object_id' => $cableID['object1_id'])) . '">' . $cableID['object1_name'] . ': ' . $cableID['object1_port'] . '</a></td>' . '<td><a href="' . makeHref(array('page' => 'object', 'object_id' => $cableID['object2_id'])) . '">' . $cableID['object2_name'] . ': ' . $cableID['object2_port'] . '</a></td>' . '</tr>';
$i++;
}
echo ' </tbody>' . '</table>';
}
开发者ID:cengn-tao,项目名称:racktables-contribs,代码行数:60,代码来源:cableIDHelper.php
示例7: display
function display($tpl = null)
{
JToolBarHelper::title(JText::_('JoomSEF'), 'artio.png');
// Get number of URLs for purge warning
$model =& JModel::getInstance('URLs', 'SEFModel');
$this->assign('purgeCount', $model->getCount(0));
// Get newest version available
$sefConfig =& SEFConfig::getConfig();
if ($sefConfig->versionChecker) {
$model2 =& JModel::getInstance('Upgrade', 'SEFModel');
$newVer = $model2->getNewSEFVersion();
$sefinfo = SEFTools::getSEFInfo();
if (strnatcasecmp($newVer, $sefinfo['version']) > 0 || strnatcasecmp($newVer, substr($sefinfo['version'], 0, strpos($sefinfo['version'], '-'))) == 0) {
$newVer = '<span style="font-weight: bold; color: red;">' . $newVer . '</span> <input type="button" onclick="showUpgrade();" value="' . JText::_('Go to Upgrade page') . '" />';
}
$newVer .= ' <input type="button" onclick="disableStatus(\'versioncheck\');" value="' . JText::_('Disable version checker') . '" />';
$this->assign('newestVersion', $newVer);
} else {
$newestVersion = JText::_('Version checker disabled') . ' <input type="button" onclick="enableStatus(\'versioncheck\');" value="' . JText::_('Enable') . '" />';
$this->assign('newestVersion', $newestVersion);
}
// Get statistics
$stats = $model->getStatistics();
$this->assignRef('stats', $stats);
// Get feed
$feed = $this->get('Feed');
$this->assignRef('feed', $feed);
JHTML::_('behavior.tooltip');
parent::display($tpl);
}
开发者ID:andreassetiawanhartanto,项目名称:PDKKI,代码行数:30,代码来源:view.html.php
示例8: discoverRoutes
/**
* Finds all theme route files and adds the routes to the RouteCollection.
*
* @return void
*/
private function discoverRoutes()
{
// Where are our routes located?
$parentRoutes = $this->config->paths->theme->parent->routes;
$childRoutes = $this->config->paths->theme->child->routes;
$files = $this->finder->createFinder()->files()->name('*.php')->in($parentRoutes);
if ($parentRoutes != $childRoutes && is_dir($childRoutes)) {
$files = $files->in($childRoutes);
}
// Collect all the files
$splFiles = [];
foreach ($files as $file) {
$splFiles[] = $file;
}
// Now we need to sort them ourselves because it seems Finder's
// sortByName(), only sorts per in('dir') and not across the
// entire list.
$orderedFiles = Linq::from($splFiles)->orderBy('$v', function ($a, $b) {
return strnatcasecmp($a->getBasename('.php'), $b->getBasename('.php'));
});
// Finally lets add some routes.
foreach ($orderedFiles as $file) {
$route = import($file->getRealPath(), ['route' => $this->routes]);
if (is_callable($route)) {
$this->container->call($route, ['config' => $this->config]);
}
}
}
开发者ID:fructify,项目名称:theme,代码行数:33,代码来源:Router.php
示例9: getNavigation
/**
* @return array
*/
public function getNavigation()
{
//$this->setActiveElements();
$return = [];
foreach ($this->pages as $block => $blockPages) {
if (is_array($blockPages) && count($blockPages) > 0 && $blockPages[0] instanceof rex_be_page_main) {
uasort($blockPages, function (rex_be_page_main $a, rex_be_page_main $b) {
$a_prio = (int) $a->getPrio();
$b_prio = (int) $b->getPrio();
if ($a_prio == $b_prio || $a_prio <= 0 && $b_prio <= 0) {
return strnatcasecmp($a->getTitle(), $b->getTitle());
}
if ($a_prio <= 0) {
return 1;
}
if ($b_prio <= 0) {
return -1;
}
return $a_prio > $b_prio ? 1 : -1;
});
}
$n = $this->_getNavigation($blockPages);
if (count($n) > 0) {
$fragment = new rex_fragment();
$fragment->setVar('navigation', $n, false);
$return[] = ['navigation' => $n, 'headline' => ['title' => $this->getHeadline($block)]];
}
}
return $return;
}
开发者ID:DECAF,项目名称:redaxo,代码行数:33,代码来源:navigation.php
示例10: osort
/**
* https://gist.github.com/amnuts/8633684
*/
function osort(&$array, $properties)
{
if (is_string($properties)) {
$properties = array($properties => SORT_ASC);
}
uasort($array, function ($a, $b) use($properties) {
foreach ($properties as $k => $v) {
if (is_int($k)) {
$k = $v;
$v = SORT_ASC;
}
$collapse = function ($node, $props) {
if (is_array($props)) {
foreach ($props as $prop) {
$node = !isset($node->{$prop}) ? null : $node->{$prop};
}
return $node;
} else {
return !isset($node->{$props}) ? null : $node->{$props};
}
};
$aProp = $collapse($a, $k);
$bProp = $collapse($b, $k);
if ($aProp != $bProp) {
return $v == SORT_ASC ? strnatcasecmp($aProp, $bProp) : strnatcasecmp($bProp, $aProp);
}
}
return 0;
});
}
开发者ID:drAlberT,项目名称:phperror-gui,代码行数:33,代码来源:phperror-gui.php
示例11: sortKeys
public function sortKeys()
{
usort($this->entries, function ($a, $b) {
return strnatcasecmp($a->key, $b->key);
});
return $this;
}
开发者ID:jaytaph,项目名称:Tries,代码行数:7,代码来源:TrieCollection.php
示例12: run
public function run()
{
$rules = [];
$query = Rule::find()->innerJoinWith('mode')->andWhere(['{{game_mode}}.[[key]]' => 'gachi']);
foreach ($query->all() as $rule) {
$rules[$rule->id] = Yii::t('app-rule', $rule->name);
}
asort($rules);
$maps = [];
foreach (Map::find()->all() as $map) {
$maps[$map->id] = [$map->key, Yii::t('app-map', $map->name)];
}
uasort($maps, function ($a, $b) {
return strnatcasecmp($a[1], $b[1]);
});
// init data
$data = [];
foreach (array_keys($maps) as $mapId) {
$data[$mapId] = [];
foreach (array_keys($rules) as $ruleId) {
$data[$mapId][$ruleId] = (object) ['battle_count' => 0, 'ko_count' => 0];
}
}
// set data
foreach ($this->query() as $row) {
$ruleId = $row['rule_id'];
$mapId = $row['map_id'];
$data[$mapId][$ruleId]->battle_count = (int) $row['battle_count'];
$data[$mapId][$ruleId]->ko_count = (int) $row['ko_count'];
}
return $this->controller->render('knockout.tpl', ['rules' => $rules, 'maps' => $maps, 'data' => $data]);
}
开发者ID:frozenpandaman,项目名称:stat.ink,代码行数:32,代码来源:KnockoutAction.php
示例13: getEvents
/**
* Get events.
*
* @return array
*/
public function getEvents()
{
uasort($this->events, function ($a, $b) {
return strnatcasecmp($a['label'], $b['label']);
});
return $this->events;
}
开发者ID:dongilbert,项目名称:mautic,代码行数:12,代码来源:TriggerBuilderEvent.php
示例14: getActions
/**
* Get actions
*
* @return array
*/
public function getActions()
{
uasort($this->actions, function ($a, $b) {
return strnatcasecmp($a['label'], $b['label']);
});
return $this->actions;
}
开发者ID:woakes070048,项目名称:mautic,代码行数:12,代码来源:PointBuilderEvent.php
示例15: getIterator
/**
* {@inheritdoc}
*/
public function getIterator()
{
$array = iterator_to_array($this->iterator);
$sort = is_callable($this->sort) ? 'callback' : $this->sort;
$normalize = function ($string) {
$string = preg_replace("/(?<=[aou])̈/i", '', $string);
$string = mb_strtolower($string);
$string = str_replace(array('ä', 'ö', 'ü', 'ß'), array('a', 'o', 'u', 's'), $string);
return $string;
};
$sortCallback = function ($a, $b) use($normalize) {
$a = $normalize($a);
$b = $normalize($b);
return strnatcasecmp($a, $b);
};
switch ($sort) {
case self::VALUES:
uasort($array, $sortCallback);
break;
case self::KEYS:
uksort($array, $sortCallback);
break;
case 'callback':
uasort($array, $this->sort);
break;
default:
throw new Exception('Unknown sort mode!');
}
return new ArrayIterator($array);
}
开发者ID:Barnhiac,项目名称:MTW_REDAXO,代码行数:33,代码来源:sortable_iterator.php
示例16: display
function display($tpl = null)
{
JToolBarHelper::title(JText::_('COM_SEF_JOOMSEF'), 'artio.png');
$user = JFactory::getUser();
if ($user->authorise('core.admin', 'com_sef')) {
JToolBarHelper::preferences('com_sef');
}
// Get number of URLs for purge warning
$model = SEFModel::getInstance('URLs', 'SEFModel');
$this->assign('purgeCount', $model->getCount(0));
// Get newest version available
$sefConfig = SEFConfig::getConfig();
if ($sefConfig->versionChecker) {
$model2 = SEFModel::getInstance('Upgrade', 'SEFModel');
$newVer = $model2->getNewSEFVersion();
$sefinfo = SEFTools::getSEFInfo();
if (strnatcasecmp($newVer, $sefinfo['version']) > 0 || strnatcasecmp($newVer, substr($sefinfo['version'], 0, strpos($sefinfo['version'], '-'))) == 0) {
$newVer = '<span style="font-weight: bold; color: red;">' . $newVer . '</span> <input type="button" class="btn btn-small" onclick="showUpgrade();" value="' . JText::_('COM_SEF_GO_TO_UPGRADE_PAGE') . '" />';
}
$newVer .= ' <input type="button" class="btn btn-danger btn-small" onclick="disableStatus(\'versioncheck\');" value="' . JText::_('COM_SEF_DISABLE_VERSION_CHECKER') . '" />';
$this->assign('newestVersion', $newVer);
} else {
$newestVersion = JText::_('COM_SEF_VERSION_CHECKER_DISABLED') . ' <input type="button" class="btn btn-success btn-small" onclick="enableStatus(\'versioncheck\');" value="' . JText::_('COM_SEF_ENABLE') . '" />';
$this->assign('newestVersion', $newestVersion);
}
// Get statistics
$stats = $model->getStatistics();
$this->assignRef('stats', $stats);
// Get feed
$feed = $this->get('Feed');
$this->assignRef('feed', $feed);
// Check language filter plugin
$this->getModel('sef')->checkLanguagePlugins();
parent::display($tpl);
}
开发者ID:01J,项目名称:bealtine,代码行数:35,代码来源:view.html.php
示例17: sort
/**
* Sort data using the given order.
*
* Uses indexes to retain order of equal elements - stable sorting.
*
* @param array $data
* @param array|string $order [optional]
* @return array
*/
public function sort(array $data, $order = array())
{
$order = $this->prepareOrder($order);
if (empty($order)) {
return $data;
}
$index = 0;
foreach ($data as &$item) {
$item = array($index++, $item);
}
usort($data, function ($a, $b) use($order) {
foreach ($order as $field => $direction) {
if (!isset($a[1][$field]) || !isset($b[1][$field])) {
continue;
}
$result = strnatcasecmp($a[1][$field], $b[1][$field]);
if ($result === 0) {
continue;
}
if ($direction === 'desc') {
return $result - $result * 2;
}
return $result;
}
return $a[0] - $b[0];
});
foreach ($data as &$item) {
$item = $item[1];
}
return $data;
}
开发者ID:darya,项目名称:framework,代码行数:40,代码来源:Sorter.php
示例18: file_list
/**
* Create a list of the files in the torrent and their sizes as well as the total torrent size
*
* @return array with a list of files and file sizes
*/
public function file_list()
{
if (empty($this->Dec)) {
return false;
}
$InfoDict =& $this->Dec['info'];
if (!isset($InfoDict['files'])) {
// Single-file torrent
$this->Size = Int64::is_int($InfoDict['length']) ? Int64::get($InfoDict['length']) : $InfoDict['length'];
$Name = isset($InfoDict['name.utf-8']) ? $InfoDict['name.utf-8'] : $InfoDict['name'];
$this->Files[] = array($this->Size, $Name);
} else {
if (isset($InfoDict['path.utf-8']['files'][0])) {
$this->PathKey = 'path.utf-8';
}
foreach ($InfoDict['files'] as $File) {
$TmpPath = array();
foreach ($File[$this->PathKey] as $SubPath) {
$TmpPath[] = $SubPath;
}
$CurSize = Int64::is_int($File['length']) ? Int64::get($File['length']) : $File['length'];
$this->Files[] = array($CurSize, implode('/', $TmpPath));
$this->Size += $CurSize;
}
uasort($this->Files, function ($a, $b) {
return strnatcasecmp($a[1], $b[1]);
});
}
return array($this->Size, $this->Files);
}
开发者ID:Kufirc,项目名称:Gazelle,代码行数:35,代码来源:bencodetorrent.class.php
示例19: compare
/**
* Compare to css property names by name, browser-prefix and level.
*
* @param string $propertyNameOne
* @param string $propertyNameTwo
* @return integer
*/
public function compare($propertyNameOne, $propertyNameTwo)
{
$propertyOne = $this->_decodeName($propertyNameOne);
$propertyTwo = $this->_decodeName($propertyNameTwo);
$propertyOneLevels = count($propertyOne);
$propertyTwoLevels = count($propertyTwo);
$maxLevels = $propertyOneLevels > $propertyTwoLevels ? $propertyOneLevels : $propertyTwoLevels;
for ($i = 0; $i < $maxLevels; ++$i) {
if (isset($propertyOne[$i]) && isset($propertyTwo[$i])) {
$compare = strnatcasecmp($propertyOne[$i], $propertyTwo[$i]);
if ($compare != 0) {
return $compare;
}
} else {
break;
}
}
if ($propertyOneLevels > $propertyTwoLevels) {
return 1;
} elseif ($propertyOneLevels < $propertyTwoLevels) {
return -1;
} else {
return 0;
}
}
开发者ID:fluentdom,项目名称:fluentdom,代码行数:32,代码来源:PropertyCompare.php
示例20: getData
public function getData()
{
$index = array('list' => array(), 'tags' => array());
$configPaths = $this->kernel->getConfigPath();
foreach ($configPaths as $path) {
$configs = $this->getConfigs($path);
foreach ($configs as $config) {
$index['list'][] = $config;
if (!empty($config['tags'])) {
foreach ($config['tags'] as $tagName) {
// check if tag array exists, and create if needed
if (empty($index['tags'][$tagName])) {
$index['tags'][$tagName] = array('name' => $tagName, 'list' => array());
}
$index['tags'][$tagName]['list'][] = $config;
}
}
}
}
// sort by name
usort($index['list'], function ($a, $b) {
return strnatcasecmp($a['name'], $b['name']);
});
$index['tags'] = array_values($index['tags']);
return $index;
}
开发者ID:hoborglabs,项目名称:widgets,代码行数:26,代码来源:Index.php
注:本文中的strnatcasecmp函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论