本文整理汇总了PHP中ArrayObject::asort方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayObject::asort方法的具体用法?PHP ArrayObject::asort怎么用?PHP ArrayObject::asort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayObject
的用法示例。
在下文中一共展示了ArrayObject::asort方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function it_proxies_method_calls_to_wrapped_object(\ArrayObject $obj, WrappedObject $wrappedObject)
{
$obj->asort()->shouldBeCalled();
$wrappedObject->isInstantiated()->willReturn(true);
$wrappedObject->getInstance()->willReturn($obj);
$this->call('asort');
}
示例2:
function it_proxies_method_calls_to_wrapped_object(\ArrayObject $obj, WrappedObject $wrappedObject, AccessInspectorInterface $accessInspector)
{
$obj->asort()->shouldBeCalled();
$wrappedObject->isInstantiated()->willReturn(true);
$wrappedObject->getInstance()->willReturn($obj);
$accessInspector->isMethodCallable(Argument::type('ArrayObject'), 'asort')->willReturn(true);
$this->call('asort');
}
示例3: getArrayProfilSorted
/**
* get an array sorted by value.
*/
public function getArrayProfilSorted()
{
$resArraySorted = new ArrayObject($this->getArrayProfil());
$resArraySorted->asort();
return $resArraySorted;
}
示例4: array
<?php
$array = array('IMG0.png', 'img12.png', 'img10.png', 'img2.png', 'img1.png', 'IMG3.png');
$arr1 = new ArrayObject($array);
$arr2 = clone $arr1;
$arr1->asort();
echo "Standard sorting\n";
print_r($arr1);
$arr2->natcasesort();
echo "\nNatural order sorting (case-insensitive)\n";
print_r($arr2);
示例5: microtime
$memory = memory_get_usage(1);
$time = microtime(1);
for ($i = 0; $i < 1000; $i++) {
$plist->insert("zero#{$i}", -$i);
}
printf("\nnset plist: time: %f, memory: %d KB\n", microtime(1) - $time, round((memory_get_usage(1) - $memory) / 1000, 2));
$memory = memory_get_usage(1);
$time = microtime(1);
for ($i = 0; $i < 1000; $i++) {
$top = $slist->first();
}
printf("\ntop slist: time: %f, memory: %d KB\n", microtime(1) - $time, round((memory_get_usage(1) - $memory) / 1000, 2));
$memory = memory_get_usage(1);
$time = microtime(1);
for ($i = 0; $i < 1000; $i++) {
$alist->asort();
$top = key($alist);
}
printf("\ntop alist: time: %f, memory: %d KB\n", microtime(1) - $time, round((memory_get_usage(1) - $memory) / 1000, 2));
$memory = memory_get_usage(1);
$time = microtime(1);
for ($i = 0; $i < 1000; $i++) {
$top = $plist->top();
}
printf("\ntop plist: time: %f, memory: %d KB\n", microtime(1) - $time, round((memory_get_usage(1) - $memory) / 1000, 2));
$memory = memory_get_usage(1);
$time = microtime(1);
for ($i = 0; $i < 1000; $i++) {
$item = $slist->get($i);
}
printf("\nget slist: time: %f, memory: %d KB\n", microtime(1) - $time, round((memory_get_usage(1) - $memory) / 1000, 2));
示例6: ArrayObject
<?php
// SPL stands for Standard PHP Library
$fruits = ["dollar" => 10, "sterlin" => 5, "euro" => 25];
$obj = new ArrayObject($fruits);
foreach ($obj as $key => $value) {
echo "{$key} ... {$value}" . PHP_EOL;
}
$obj->asort();
foreach ($obj as $key => $value) {
echo "{$key} ... {$value}" . PHP_EOL;
}
$obj->ksort();
foreach ($obj as $key => $value) {
echo "{$key} ... {$value}" . PHP_EOL;
}
/*
Flag Effect
ArrayObject::STD_PROP_LIST Properties of the object have their normal functionality when accessed as list (var_dump, foreach, etc.).
ArrayObject::ARRAY_AS_PROPS Entries can be accessed as properties (read and write).
*/
var_dump($obj->dollar);
$obj->setFlags(ArrayObject::ARRAY_AS_PROPS);
var_dump($obj->dollar);
foreach ($obj as $key => $value) {
echo "{$key} => {$value}" . PHP_EOL;
}
示例7: ArrayObject
<?php
/* Prototype : int ArrayObject::asort()
* Description: proto int ArrayIterator::asort()
* Sort the entries by values.
* Source code: ext/spl/spl_array.c
* Alias to functions:
*/
echo "*** Testing ArrayObject::asort() : basic functionality ***\n";
$ao1 = new ArrayObject(array(4, 2, 3));
$ao2 = new ArrayObject(array('a' => 4, 'b' => 2, 'c' => 3));
var_dump($ao1->asort());
var_dump($ao1);
var_dump($ao2->asort('blah'));
var_dump($ao2);
var_dump($ao2->asort(SORT_NUMERIC));
var_dump($ao2);
?>
===DONE===
示例8: array
<?php
$fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple");
$fruitArrayObject = new ArrayObject($fruits);
$fruitArrayObject->asort();
foreach ($fruitArrayObject as $key => $val) {
echo "{$key} = {$val}\n";
}
示例9: C
<?php
/* Prototype : int ArrayObject::asort()
* Description: proto int ArrayIterator::asort()
* Sort the entries by values.
* Source code: ext/spl/spl_array.c
* Alias to functions:
*/
echo "*** Testing ArrayObject::asort() : basic functionality ***\n";
class C
{
public $prop1 = 'x';
public $prop2 = 'z';
private $prop3 = 'a';
public $prop4 = 'x';
}
$c = new C();
$ao1 = new ArrayObject($c);
var_dump($ao1->asort());
var_dump($ao1, $c);
?>
===DONE===
示例10: asort
public function asort()
{
$this->lazyLoadArray();
parent::asort();
}
示例11: asort
/**
* Implementation of ArrayObject::asort().
*
* Sorts the entries such that the keys maintain their correlation with the
* entries they are associated with. This is used mainly when sorting
* associative arrays where the actual element order is significant.
*
* No value is returned.
*/
public function asort()
{
$this->arrayObject->asort();
}