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


PHP StringHelper::explode方法代码示例

本文整理汇总了PHP中yii\helpers\StringHelper::explode方法的典型用法代码示例。如果您正苦于以下问题:PHP StringHelper::explode方法的具体用法?PHP StringHelper::explode怎么用?PHP StringHelper::explode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\helpers\StringHelper的用法示例。


在下文中一共展示了StringHelper::explode方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: rules

 public function rules()
 {
     return [[['type_in', 'hdomain_id_in'], 'filter', 'filter' => function ($value) {
         $res = StringHelper::explode($value, ',', true, true);
         return $res;
     }, 'skipOnArray' => true, 'on' => ['export-hosts']], [['type_in'], 'default', 'value' => ['a', 'aaaa'], 'on' => ['export-hosts']], [['type_in'], 'each', 'rule' => ['in', 'range' => array_keys($this->getTypes())], 'on' => ['export-hosts']], [['hdomain_id_in'], 'required', 'on' => ['export-hosts']]];
 }
开发者ID:hiqdev,项目名称:hipanel-module-dns,代码行数:7,代码来源:RecordSearch.php

示例2: locationStringToGeometry

 public static function locationStringToGeometry($location)
 {
     if (preg_match('/^(\\-?\\d+(\\.\\d+)?),(\\-?\\d+(\\.\\d+)?)$/', $location, $match)) {
         $location = \yii\helpers\StringHelper::explode($location, ',');
         return self::getPostgisFormatByCoordinate($location[0], $location[1]);
     }
     return null;
 }
开发者ID:novikovsergey,项目名称:doublegis,代码行数:8,代码来源:Building.php

示例3: getFiles

 protected function getFiles()
 {
     $value = $this->model[$this->attribute] ?: [];
     if (empty($value)) {
         return [];
     }
     if (is_string($value)) {
         $value = StringHelper::explode($value);
     }
     $value = $this->multiple ? $value : [$value[0]];
     return array_map(function ($fileModel) {
         /** @var File $fileModel */
         return $fileModel->getExtendedAttributes();
     }, File::findAll($value));
 }
开发者ID:ExtPoint,项目名称:project-boilerplate,代码行数:15,代码来源:FileInput.php

示例4: beforeAction

 public function beforeAction($action)
 {
     $route = Yii::$app->requestedRoute;
     if ($this->identity) {
         if ($this->identity->is_super) {
             $allowAccess = true;
         } else {
             // 权限验证
             $userMenuIdList = [];
             $groupMenuIdList = [];
             if ($this->identity->is_user_access) {
                 // 用户权限列表
                 $userMenuIdList = DpAdminUserMenuRelation::getAllMenuIdArrByUserId($this->identity->user_id);
             }
             if ($this->identity->is_group_access) {
                 // 用户组权限列表
                 $groupMenuIdList = DpAdminGroup::getMenuIdArrByGroupIdArr($this->identity->getGroupIdArr());
             }
             $this->menuIdList = array_merge($userMenuIdList, $groupMenuIdList);
             $routeWhiteList = ['', 'admin/common/tree', 'admin/common/urls', 'admin/public/logout'];
             $allowAccess = in_array($route, $routeWhiteList);
             if (!$allowAccess) {
                 $queryParams = Yii::$app->request->queryParams;
                 $method = Yii::$app->request->method;
                 $urlRule = DpAdminMenuUrl::getUrlRuleByMenuIdArr($this->menuIdList);
                 $allowAccess = !!array_filter($urlRule, function ($item) use($route, $queryParams, $method) {
                     if (strpos($item['route'], '/') === 0) {
                         $ruleRoute = substr($item['route'], 1, strlen($item['route']));
                     } else {
                         $ruleRoute = $item['route'];
                     }
                     if ($ruleRoute == $route) {
                         // 请求方法验证
                         if (!in_array($method, StringHelper::explode($item['method'], ',', true, true))) {
                             return false;
                         }
                         if ($item['enable_rule']) {
                             // get参数规则验证
                             foreach ($queryParams as $qk => $qv) {
                                 if (isset($item['rule'][$qk])) {
                                     $pattern = '/' . $item['rule'][$qk] . '/';
                                     if (preg_match($pattern, $qv)) {
                                         return true;
                                     }
                                 }
                             }
                             return false;
                         } else {
                             return true;
                         }
                     }
                     return false;
                 });
             }
         }
         if (!$allowAccess) {
             // 权限不足
             $response = Yii::$app->response;
             $response->format = Response::FORMAT_JSON;
             $response->data = ['success' => false, 'msg' => '权限不足', 'code' => 2];
             return false;
         } else {
             return parent::beforeAction($action);
         }
     } else {
         $routeWhiteList = ['', 'admin/public/login', 'admin/public/logout'];
         $allowAccess = in_array($route, $routeWhiteList);
         if (!$allowAccess) {
             // 未登录
             $response = Yii::$app->response;
             $response->format = Response::FORMAT_JSON;
             $response->data = ['success' => false, 'msg' => '请先登录系统', 'code' => 1];
             return false;
         }
     }
     return parent::beforeAction($action);
 }
开发者ID:phpsong,项目名称:yii2-extjs-rbac,代码行数:77,代码来源:Controller.php

示例5: getFileBetweenCommits

 /**
  * 获取commit之间的文件
  *
  * @return array
  */
 public function getFileBetweenCommits($branch, $star, $end)
 {
     // 先更新
     $destination = Project::getDeployFromDir();
     $this->updateRepo($branch, $destination);
     $cmd[] = sprintf('cd %s ', static::getBranchDir($branch, $this->getConfig()->repo_mode == Project::REPO_TAG ?: false));
     $cmd[] = $this->_getSvnCmd(sprintf('svn diff -r %d:%d --summarize', $star, $end));
     $command = join(' && ', $cmd);
     $result = $this->runLocalCommand($command);
     if (!$result) {
         throw new \Exception('获取提交历史失败:' . $this->getExeLog());
     }
     $list = [];
     $files = StringHelper::explode($this->getExeLog(), PHP_EOL);
     $files = array_map(function ($item) {
         return trim(substr($item, strpos($item, " ")));
     }, $files);
     // 排除点文件
     if (in_array('.', $files)) {
         unset($files[array_search('.', $files)]);
     }
     foreach ($files as $key => $file) {
         // 如果是目录,则目录下的文件则可以不带了
         if (in_array(dirname($file), $files)) {
             continue;
         }
         $list[] = $file;
     }
     return $list;
 }
开发者ID:ShuangRen,项目名称:walle-web,代码行数:35,代码来源:Svn.php

示例6: actionUpdateStatus

 /**
  * 更新状态
  *
  * @return array
  */
 public function actionUpdateStatus()
 {
     $ids = \Yii::$app->request->post('ids');
     $status = intval(\Yii::$app->request->post('status'));
     if ($status != 0) {
         $status = 1;
     }
     foreach (StringHelper::explode($ids, ',', true, true) as $id) {
         $obj = DpAdminGroup::find()->findByGroupId($id)->one();
         if ($obj) {
             $obj->status = $status;
             $obj->save();
         }
     }
     return $this->renderSuccess('状态更新成功');
 }
开发者ID:phpsong,项目名称:yii2-extjs-rbac,代码行数:21,代码来源:GroupController.php

示例7: init

 public function init()
 {
     parent::init();
     if (is_string($this->data) || is_numeric($this->data)) {
         $this->data = StringHelper::explode($this->data);
     } elseif ($this->data === null) {
         $this->data = [];
     }
     if (empty($this->mode)) {
         $this->mode = static::MODE_POPOVER;
     }
     if (!is_callable([$this, 'renderButton' . Inflector::id2camel($this->mode)])) {
         throw new InvalidValueException('Do not know, how to render button of this type');
     }
     if (is_string($this->button)) {
         $this->button = ['label' => $this->button];
     }
     $this->button = ArrayHelper::merge(['tag' => 'a', 'id' => $this->id], $this->button);
     if (!is_array($this->data)) {
         throw new InvalidValueException('Input can not be processed as an array');
     }
     if (is_callable($this->formatter)) {
         $this->data = array_map($this->formatter, $this->data, array_keys($this->data));
     }
     if (is_callable($this->button['label'])) {
         $this->button['label'] = call_user_func($this->button['label'], $this);
     }
 }
开发者ID:hiqdev,项目名称:hipanel-core,代码行数:28,代码来源:ArraySpoiler.php

示例8: setHorasHombre

 public function setHorasHombre()
 {
     $horai = StringHelper::explode($this->hora_ini, ':', true, false);
     $horaf = StringHelper::explode($this->hora_fin, ':', true, false);
     if ($horaf[0] == $horai[0]) {
         $this->HH = ($horaf[1] - $horai[1]) / 60;
     } else {
         $this->HH = (60 * ($horaf[0] - $horai[0]) - $horai[1] + $horaf[1]) / 60;
     }
 }
开发者ID:noeliovando,项目名称:yii2advance,代码行数:10,代码来源:Actividad.php

示例9: getGroupIdArr

 /**
  * 获取用户组id数组
  *
  * @return array
  */
 public function getGroupIdArr()
 {
     $return = [];
     if ($this->group_ids) {
         $return = array_filter(StringHelper::explode($this->group_ids, ',', true, true), function ($groupId) {
             return is_numeric($groupId) && DpAdminGroup::find()->findByGroupId($groupId)->exists();
         });
     }
     return $return;
 }
开发者ID:phpsong,项目名称:yii2-extjs-rbac,代码行数:15,代码来源:DpAdminUser.php

示例10: getFileAndVersionList

 /**
  * 获取文件和版本号列表
  *
  * @param TaskModel $task
  * @return array
  */
 public function getFileAndVersionList(TaskModel $task)
 {
     $fileList = GlobalHelper::str2arr($task->file_list);
     $fileAndVersion = [];
     foreach ($fileList as $file) {
         list($file, $version) = array_pad(StringHelper::explode($file, ' ', true, true), 2, null);
         $fileAndVersion[] = ['file' => $file, 'version' => $version];
     }
     return $fileAndVersion;
 }
开发者ID:charlestang,项目名称:walle-web,代码行数:16,代码来源:Svn.php

示例11: dragSort

 /**
  * 拖拽排序
  *
  * @return bool
  */
 public function dragSort()
 {
     if ($this->validate()) {
         $menuModel = DpAdminMenu::find()->findByMenuId($this->target_menu_id)->one();
         // 调整排序的菜单id
         $dropMenuIdArr = array_filter(StringHelper::explode($this->menu_ids, ',', true, true), function ($value) {
             return is_numeric($value) && DpAdminMenu::find()->findByMenuId($value)->exists();
         });
         // 调整排序菜单数量
         $dropCount = count($dropMenuIdArr);
         if (static::POSITION_BEFORE == $this->position) {
             // 节点之前
             $menuAllObj = DpAdminMenu::find()->findByParentId($menuModel->parent_id)->orderBy('display_order asc')->all();
             // 将要插入的菜单前面的排序向前移动
             // 插入的开始排序号
             $startOrder = $menuModel->display_order - 1;
             $otherStartOrder = $startOrder - $dropCount;
             foreach ($menuAllObj as $menuObj) {
                 if ($menuObj->menu_id == $menuModel->menu_id) {
                     break;
                 }
                 $menuObj->display_order = $otherStartOrder--;
                 $menuObj->save();
             }
             $dropStartOrder = $menuModel->display_order - $dropCount;
             foreach ($dropMenuIdArr as $menuId) {
                 $dropMenu = DpAdminMenu::find()->findByMenuId($menuId)->one();
                 if ($dropMenu) {
                     $dropMenu->parent_id = $menuModel->parent_id;
                     $dropMenu->display_order = $dropStartOrder++;
                     $dropMenu->save();
                 }
             }
             return true;
         } elseif (static::POSITION_AFTER == $this->position) {
             // 节点之后
             // 在菜单后插入
             $menuAllObj = DpAdminMenu::find()->findByParentId($menuModel->parent_id)->andWhere('menu_id not in (' . join(',', $dropMenuIdArr) . ')')->all();
             // 将要插入的菜单后面的排序向后移动
             // 插入的开始排序号
             $isStartOrder = false;
             $startOrder = $menuModel->display_order + 1;
             $otherStartOrder = $startOrder + $dropCount;
             foreach ($menuAllObj as $menuObj) {
                 if ($menuObj->menu_id == $menuModel->menu_id) {
                     $isStartOrder = true;
                     continue;
                 }
                 if (!$isStartOrder) {
                     continue;
                 }
                 $menuObj->display_order = $otherStartOrder++;
                 $menuObj->save();
             }
             foreach ($dropMenuIdArr as $menuId) {
                 $dropMenu = DpAdminMenu::find()->findByMenuId($menuId)->one();
                 if ($dropMenu) {
                     $dropMenu->parent_id = $menuModel->parent_id;
                     $dropMenu->display_order = $startOrder++;
                     $dropMenu->save();
                 }
             }
             return true;
         } elseif (static::POSITION_APPEND == $this->position) {
             // 节点内
             // 添加为子节点
             $maxDisplayOrder = DpAdminMenu::find()->findByParentId($menuModel->menu_id)->max('display_order');
             foreach ($dropMenuIdArr as $menuId) {
                 $dropMenu = DpAdminMenu::find()->findByMenuId($menuId)->one();
                 if ($dropMenu) {
                     $dropMenu->parent_id = $menuModel->menu_id;
                     $dropMenu->display_order = ++$maxDisplayOrder;
                     $dropMenu->save();
                 }
             }
             return true;
         }
     }
     return false;
 }
开发者ID:Jasmine2,项目名称:yii2-extjs-rbac,代码行数:85,代码来源:DpAdminMenuForm.php

示例12: getIds

 private function getIds($get_param_name)
 {
     $ids = null;
     $get_ids = \Yii::$app->request->getQueryParam($get_param_name);
     if (!empty($get_ids)) {
         $ids = StringHelper::explode($get_ids, ',');
         foreach ($ids as $key => $id) {
             if (!(int) $id) {
                 throw new \yii\web\BadRequestHttpException();
             }
             $ids[$key] = (int) $id;
         }
     }
     return $ids;
 }
开发者ID:novikovsergey,项目名称:doublegis,代码行数:15,代码来源:MainController.php

示例13: actionClonar

 public function actionClonar($id)
 {
     $obj = Actividad::find()->where(['id_actividad' => $id])->one();
     $fechar = StringHelper::explode(ArrayHelper::getValue($obj, 'fecha_requerimiento'), '-');
     $fechaa = StringHelper::explode(ArrayHelper::getValue($obj, 'fecha_atencion'), '-');
     $diar = $fechar[2] + 1;
     $diaa = $fechaa[2] + 1;
     $clone = new Actividad(['attributes' => $obj->getAttributes(), 'codigo_caso' => $obj->getCodigoActividad(), 'fecha_requerimiento' => $fechar[0] . '-' . $fechar[1] . '-' . $diar, 'fecha_atencion' => $fechaa[0] . '-' . $fechaa[1] . '-' . $diaa]);
     $clone->save();
     return $this->render('view', ['model' => $this->findModel($clone->id_actividad)]);
 }
开发者ID:noeliovando,项目名称:yii2advance,代码行数:11,代码来源:ActividadController.php

示例14: testExplode

 public function testExplode()
 {
     $this->assertEquals(['It', 'is', 'a first', 'test'], StringHelper::explode("It, is, a first, test"));
     $this->assertEquals(['It', 'is', 'a second', 'test'], StringHelper::explode("It+ is+ a second+ test", '+'));
     $this->assertEquals(['Save', '', '', 'empty trimmed string'], StringHelper::explode("Save, ,, empty trimmed string", ','));
     $this->assertEquals(['Здесь', 'multibyte', 'строка'], StringHelper::explode("Здесь我 multibyte我 строка", '我'));
     $this->assertEquals(['Disable', '  trim  ', 'here but ignore empty'], StringHelper::explode("Disable,  trim  ,,,here but ignore empty", ',', false, true));
 }
开发者ID:howq,项目名称:yii2,代码行数:8,代码来源:StringHelperTest.php


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