本文整理汇总了PHP中Arr::sort方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::sort方法的具体用法?PHP Arr::sort怎么用?PHP Arr::sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arr
的用法示例。
在下文中一共展示了Arr::sort方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sort
/**
* Tri un tableau
*/
public static function sort(&$obj, $key, $order = SORT_DESC)
{
if ($obj) {
self::toArray($obj);
Arr::sort($obj, $key, $order);
Arr::toObject($obj);
}
}
示例2: array_sort
/**
* Sort the array using the given Closure.
*
* @param array $array
* @param \Closure $callback
* @return array
*/
function array_sort($array, Closure $callback)
{
return Arr::sort($array, $callback);
}
示例3: test_sort_invalid_direction
/**
* Tests Arr::sort()
*
* @test
* @dataProvider sort_provider
* @expectedException InvalidArgumentException
*/
public function test_sort_invalid_direction($data, $expected)
{
$this->assertEquals(Arr::sort($data, 'info.pet.type', 'downer'), $expected);
}
示例4: test_sort_empty
public function test_sort_empty()
{
$expected = array();
$output = Arr::sort(array(), 'test', 'test');
$this->assertEquals($expected, $output);
}
示例5: shipping_price
/**
* Calculate order shipping price
*
* @param type $postcode = Postcode to calculate price
* @param type $default = Default return value if postcode dont exist or not set
* @param type $default =
* @return type
*/
public function shipping_price($postcode = null, $default = null, $force_current_user = false)
{
// Default postcode to users postcode
if (is_null($postcode)) {
if ($force_current_user) {
if (\Model_Base::check_logged()) {
$user = \Sentry::user();
$postcode = $user->get('metadata.postcode');
}
} else {
$postcode = $this->user->get('metadata.postcode');
}
}
// Load shipping configuration
\Config::load('product::shipping', 'shipping', true);
$prices = \Arr::sort(\Config::get('shipping.price', array()), 'from');
if (!is_numeric($default)) {
$default = \Config::get('shipping.default', 0);
}
$target_price = $default;
// If we dont have postcode we return zero shipping price
if (!$postcode || !is_numeric($postcode)) {
return $target_price;
}
// Find coresponding price for this postcode
foreach ($prices as $price) {
if ($price['from'] <= $postcode && $price['to'] >= $postcode) {
$target_price = $price['price'];
break;
}
}
// return $target_price;
// no shipping price for enviroform site
return $default;
}