本文整理汇总了PHP中strnatcasecmp函数的典型用法代码示例。如果您正苦于以下问题:PHP strnatcasecmp函数的具体用法?PHP strnatcasecmp怎么用?PHP strnatcasecmp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了strnatcasecmp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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();
}
}
示例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;
}
示例4: compare_rows
function compare_rows($a, $b)
{
if (-1 == $this->column) {
return 0;
}
return strnatcasecmp($a[$this->column], $b[$this->column]);
}
示例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);
}
示例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>';
}
示例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);
}
示例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]);
}
}
}
示例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;
}
示例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;
});
}
示例11: sortKeys
public function sortKeys()
{
usort($this->entries, function ($a, $b) {
return strnatcasecmp($a->key, $b->key);
});
return $this;
}
示例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]);
}
示例13: getEvents
/**
* Get events.
*
* @return array
*/
public function getEvents()
{
uasort($this->events, function ($a, $b) {
return strnatcasecmp($a['label'], $b['label']);
});
return $this->events;
}
示例14: getActions
/**
* Get actions
*
* @return array
*/
public function getActions()
{
uasort($this->actions, function ($a, $b) {
return strnatcasecmp($a['label'], $b['label']);
});
return $this->actions;
}
示例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);
}