当前位置: 首页>>代码示例>>PHP>>正文


PHP Arr::init方法代码示例

本文整理汇总了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;
 }
开发者ID:nikonehauser,项目名称:pt,代码行数:13,代码来源:FormBuilder.php

示例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;
 }
开发者ID:mk-pmb,项目名称:js2php,代码行数:22,代码来源:Array.php

示例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);
 }
开发者ID:nikonehauser,项目名称:ptclient,代码行数:30,代码来源:account.controller.php

示例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) {
开发者ID:mk-pmb,项目名称:js2php,代码行数:31,代码来源:String.php

示例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]);
}
开发者ID:nikonehauser,项目名称:pt,代码行数:27,代码来源:api.php

示例6: get

 public static function get($key, $type = TYPE_STRING, $default = false)
 {
     return Arr::init($_SESSION, $key, $type, $default);
 }
开发者ID:nikonehauser,项目名称:pt,代码行数:4,代码来源:Session.php

示例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) {
开发者ID:mk-pmb,项目名称:js2php,代码行数:31,代码来源:Object.php

示例8: get

 public static function get($name, $type = TYPE_STRING, $default = false)
 {
     return Arr::init(self::$struct, $name, $type, $default);
 }
开发者ID:nikonehauser,项目名称:pt,代码行数:4,代码来源:Config.php

示例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);
 }
开发者ID:nikonehauser,项目名称:pt,代码行数:21,代码来源:account.controller.php


注:本文中的Arr::init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。