本文整理汇总了PHP中ArrayObject::natcasesort方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayObject::natcasesort方法的具体用法?PHP ArrayObject::natcasesort怎么用?PHP ArrayObject::natcasesort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayObject
的用法示例。
在下文中一共展示了ArrayObject::natcasesort方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
<?php
$array = array('koala', 'kangaroo', 'wombat', 'wallaby', 'emu', 'kiwi', 'kookaburra', 'platypus');
/*** create the array object ***/
$arrayObj = new ArrayObject($array);
/*append a new value in the array*/
$arrayObj->append('dingo');
/*Sort a arrayobject */
$arrayObj->natcasesort();
/*Get the iterator obj*/
$iterator = $arrayObj->getIterator();
$arrayObj->offsetUnset(5);
if ($arrayObj->offsetExists(4)) {
echo "Offset exitst" . "<br>";
}
/*Count the total array*/
echo "Total amount of " . $arrayObj->count() . "<br>";
/*Get traverse the whole the array*/
while ($iterator->valid()) {
echo $iterator->key() . ' => ' . $iterator->current() . '<br />';
$iterator->next();
}
示例2: array
<?php
//重点是演示ArrayObject中的natcasesort()方法
$array = array('koala', 'kangaroo', 'wombat', 'wallaby', 'emu', 'kiwi', 'kookaburra', 'platypeus');
$array_obj = new ArrayObject($array);
$array_obj->natcasesort();
for ($iterator = $array_obj->getIterator(); $iterator->valid(); $iterator->next()) {
echo $iterator->key(), "=>", $iterator->current(), "\n";
}
示例3: natcasesort
public function natcasesort()
{
$this->lazyLoadArray();
parent::natcasesort();
}
示例4: ArrayObject
<?php
/* Prototype : int ArrayObject::natcasesort()
* Description: proto int ArrayIterator::natcasesort()
Sort the entries by values using case insensitive "natural order" algorithm.
* Source code: ext/spl/spl_array.c
* Alias to functions:
*/
echo "*** Testing ArrayObject::natcasesort() : basic functionality ***\n";
$ao1 = new ArrayObject(array('boo10', 'boo1', 'boo2', 'boo22', 'BOO5'));
$ao2 = new ArrayObject(array('a' => 'boo10', 'b' => 'boo1', 'c' => 'boo2', 'd' => 'boo22', 'e' => 'BOO5'));
var_dump($ao1->natcasesort());
var_dump($ao1);
var_dump($ao2->natcasesort('blah'));
var_dump($ao2);
?>
===DONE===
示例5: natcasesort
/**
* Implementation of ArrayObject::natcasesort().
*
* This method is a case insensitive version of ArrayObject::natsort.
*
* This method implements a sort algorithm that orders alphanumeric strings
* in the way a human being would while maintaining key/value associations.
* This is described as a "natural ordering".
*
* No value is returned.
*/
public function natcasesort()
{
$this->arrayObject->natcasesort();
}