本文整理汇总了PHP中Arr::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::init方法的具体用法?PHP Arr::init怎么用?PHP Arr::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arr
的用法示例。
在下文中一共展示了Arr::init方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildBonusLevelSelectGroup
public function buildBonusLevelSelectGroup($fieldKey)
{
$label = Arr::init($this->labels, $fieldKey);
$value = Arr::init($this->values, $fieldKey);
$error = Arr::init($this->errors, $fieldKey);
$fieldId = $this->formName . $fieldKey;
$group = '<div class="field">' . '<label for="' . $fieldId . '">' . $label . '</label>' . '<select name="' . $fieldKey . '">';
for ($i = 1; $i <= 10; $i++) {
$group .= '<option value="' . $i . '">Level ' . $i . '</option>';
}
$group .= '</select></div>';
return $group;
}
示例2: getGlobalConstructor
/**
* Creates the global constructor used in user-land
* @return Func
*/
static function getGlobalConstructor()
{
$Array = new Func(function ($value = null) {
$arr = new Arr();
$len = func_num_args();
if ($len === 1 && is_int_or_float($value)) {
$arr->length = (int) $value;
} else {
if ($len > 0) {
$arr->init(func_get_args());
}
}
return $arr;
});
$Array->set('prototype', Arr::$protoObject);
$Array->setMethods(Arr::$classMethods, true, false, true);
return $Array;
}
示例3: action_ajax_tree
public function action_ajax_tree(array $params = array())
{
$ids = Arr::init($_REQUEST, 'ids', TYPE_ARRAY);
$bonusOnly = Arr::init($_REQUEST, 'bonusOnly', TYPE_BOOL);
$rowCount = Arr::init($_REQUEST, 'count', TYPE_INT, 100);
$byColumn = Arr::init($_REQUEST, 'column', TYPE_STRING, 'ParentId');
$filterByColumn = "filterBy{$byColumn}";
$comparisonOperator = \Criteria::IN;
$memberTypes = Localizer::get('common.member_types');
$rows = [];
for ($i = 0; $i < $rowCount; $i++) {
$members = \MemberQuery::create()->{$filterByColumn}($ids, $comparisonOperator)->orderBy(\MemberPeer::SIGNUP_DATE, \Criteria::ASC);
if ($bonusOnly) {
$members->filterByType(\Member::TYPE_MEMBER, \Criteria::GREATER_THAN);
}
$members = $members->find();
if (count($members) === 0) {
break;
}
$row = $members->toArray();
$newIds = [];
foreach ($members as $i => $member) {
$row[$i]['TypeTranslated'] = $memberTypes[$member->getType()];
$newIds[] = $member->getId();
}
$rows[] = $row;
$ids = $newIds;
}
return new ControllerActionAjax($rows);
}
示例4: array
//$arr = mb_split($delim->source, $str);
$arr = preg_split($delim->toString(true), $str);
} else {
$delim = to_string($delim);
if ($delim === '') {
$len = mb_strlen($str);
$arr = array();
for ($i = 0; $i < $len; $i++) {
$arr[] = mb_substr($str, $i, 1);
}
} else {
$arr = explode($delim, $str);
}
}
$result = new Arr();
$result->init($arr);
return $result;
}, 'substr' => function ($start, $num = null) {
$self = Func::getContext();
$len = $self->length;
if ($len === 0) {
return '';
}
$start = (int) $start;
if ($start < 0) {
$start = $len + $start;
if ($start < 0) {
$start = 0;
}
}
if ($start >= $len) {
示例5: define
<?php
namespace Tbmt;
define('BASE_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
try {
require BASE_DIR . 'include' . DIRECTORY_SEPARATOR . 'bootstrap.php';
$apiName = Arr::init($_REQUEST, 'api');
$apiDo = Arr::init($_REQUEST, 'do');
$apiFile = API_DIR . $apiName . '.php';
if (!$apiName || !$apiDo || !file_exists($apiFile)) {
throw new PageNotFoundException();
}
$apiClassName = 'Tbmt\\' . ucfirst($apiName) . 'API';
require_once $apiFile;
(new $apiClassName())->run($apiDo);
} catch (PageNotFoundException $e) {
header("HTTP/1.0 404 Not Found");
} catch (\Exception $e) {
error_log($e->__toString());
$trace = '';
if (Config::get('devmode', TYPE_BOOL, false)) {
$trace = $e->getTraceAsString();
}
header('Content-Type: application/json');
echo json_encode(['error' => $e->getMessage(), 'trace' => $trace]);
}
示例6: get
public static function get($key, $type = TYPE_STRING, $default = false)
{
return Arr::init($_SESSION, $key, $type, $default);
}
示例7: Object
$obj = new Object();
$obj->proto = $proto;
return $obj;
}, 'keys' => function ($obj) {
if (!$obj instanceof Object) {
throw new Ex(Error::create('Object.keys called on non-object'));
}
$results = new Arr();
$results->init($obj->getOwnKeys(true));
return $results;
}, 'getOwnPropertyNames' => function ($obj) {
if (!$obj instanceof Object) {
throw new Ex(Error::create('Object.getOwnPropertyNames called on non-object'));
}
$results = new Arr();
$results->init($obj->getOwnKeys(false));
return $results;
}, 'getOwnPropertyDescriptor' => function ($obj, $key) {
if (!$obj instanceof Object) {
throw new Ex(Error::create('Object.getOwnPropertyDescriptor called on non-object'));
}
$result = $obj->get($key);
return $result ? $result->getDescriptor() : null;
}, 'defineProperty' => function ($obj, $key, $desc) {
//todo: ensure configurable
if (!$obj instanceof Object) {
throw new Ex(Error::create('Object.defineProperty called on non-object'));
}
$value = $desc->get('value');
$writable = $desc->get('writable');
if ($writable === null) {
示例8: get
public static function get($name, $type = TYPE_STRING, $default = false)
{
return Arr::init(self::$struct, $name, $type, $default);
}
示例9: action_ajax_tree
public function action_ajax_tree(array $params = array())
{
$ids = Arr::init($_REQUEST, 'ids', TYPE_ARRAY);
$rowCount = Arr::init($_REQUEST, 'count', TYPE_INT, 5);
$byColumn = Arr::init($_REQUEST, 'column', TYPE_STRING, 'ParentId');
$filterByColumn = "filterBy{$byColumn}";
$rows = [];
for ($i = 0; $i < $rowCount; $i++) {
$members = \MemberQuery::create()->{$filterByColumn}($ids, \Criteria::IN)->find();
if (count($members) === 0) {
break;
}
$rows[] = $members->toArray();
$newIds = [];
foreach ($members as $member) {
$newIds[] = $member->getId();
}
$ids = $newIds;
}
return new ControllerActionAjax($rows);
}