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


PHP key_exists函数代码示例

本文整理汇总了PHP中key_exists函数的典型用法代码示例。如果您正苦于以下问题:PHP key_exists函数的具体用法?PHP key_exists怎么用?PHP key_exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: getLabel

 /**
  * Overwrite the abstract method defined in Control, see parent comment
  * 
  * @return string
  */
 public function getLabel() : string
 {
     if (key_exists($this->getValue(), $this->getChoices())) {
         return (string) $this->getChoices()[$this->getValue()];
     }
     return $this->getValue();
 }
开发者ID:romain-pierre,项目名称:core,代码行数:12,代码来源:Choice.php

示例2: filter

 /**
  * Возвращает массив в виде дерева (многомерной иерархии)
  * Позаимствовано с http://stackoverflow.com/questions/841014/nested-sets-php-array-and-transformation
  *
  * @param array  $array Плоский массив
  * @param string $depth Ключ массива в котором лежит номер уровня
  * @param string $children Ключ массива в котором будут лежать дети
  * @return array
  */
 public function filter($array = array(), $depth = 'clevel', $children = 'children')
 {
     // Trees mapped
     $trees = array();
     $l = 0;
     if (count($array) > 0) {
         // Node Stack. Used to help building the hierarchy
         $stack = array();
         foreach ($array as $node) {
             $item = $node;
             //$item[$children] = array();
             // Number of stack items
             $l = count($stack);
             // Check if we're dealing with different levels
             while ($l > 0 && $stack[$l - 1][$depth] >= $item[$depth]) {
                 array_pop($stack);
                 $l--;
             }
             // Stack is empty (we are inspecting the root)
             if ($l == 0) {
                 // Assigning the root node
                 $i = count($trees);
                 $trees[$i] = $item;
                 $stack[] =& $trees[$i];
             } else {
                 // Add node to parent
                 $i = key_exists($children, $stack[$l - 1]) ? count($stack[$l - 1][$children]) : 0;
                 $stack[$l - 1][$children][$i] = $item;
                 $stack[] =& $stack[$l - 1][$children][$i];
             }
         }
     }
     return $trees;
 }
开发者ID:ei-grad,项目名称:phorm,代码行数:43,代码来源:Tree.php

示例3: _setEventStatus

 protected function _setEventStatus($status)
 {
     $this->requireAuthentication();
     $app = App::i();
     if (!key_exists('id', $this->urlData)) {
         $app->pass();
     }
     $entity = $this->getRequestedEntity();
     if (!$entity) {
         $app->pass();
     }
     $entity->checkPermission('@control');
     if (isset($this->data['ids']) && $this->data['ids']) {
         $ids = is_array($this->data['ids']) ? $this->data['ids'] : explode(',', $this->data['ids']);
         $events = $app->repo('Event')->findBy(['id' => $ids]);
     }
     foreach ($events as $event) {
         if (\MapasCulturais\Entities\Event::STATUS_ENABLED === $status) {
             $event->publish();
         } elseif (\MapasCulturais\Entities\Event::STATUS_DRAFT === $status) {
             $event->unpublish();
         }
     }
     $app->em->flush();
     $this->json(true);
 }
开发者ID:wagnertw,项目名称:mapasculturais,代码行数:26,代码来源:Project.php

示例4: index

 public function index(){
     $days = 7;
     $this -> assign('days', $days);
     $where = array('token' => $this -> token);
     $where['time'] = array('gt', time() - $days * 24 * 3600);
     $where['module'] = array('neq', '');
     $db = M('Share');
     $items = $db -> where($where) -> select();
     $datas = array();
     if ($items){
         foreach ($items as $item){
             if (trim($item['module'])){
                 if (!key_exists($item['module'], $datas)){
                     $datas[$item['module']] = array('module' => $item['module'], 'count' => 1, 'moduleName' => funcDict :: moduleName($item['module']));
                 }else{
                     $datas[$item['module']]['count']++;
                 }
             }
         }
     }
     $xml = '<chart borderThickness="0" caption="' . $days . '日内分享统计" baseFontColor="666666" baseFont="宋体" baseFontSize="14" bgColor="FFFFFF" bgAlpha="0" showBorder="0" bgAngle="360" pieYScale="90"  pieSliceDepth="5" smartLineColor="666666">';
     if ($datas){
         foreach ($datas as $item){
             $xml .= '<set label="' . $item['moduleName'] . '" value="' . $item['count'] . '"/>';
         }
     }
     $xml .= '</chart>';
     $this -> assign('items', $items);
     $this -> assign('xml', $xml);
     $this -> assign('list', $datas);
     $this -> assign('listinfo', 1);
     $this -> assign('tab', 'stastic');
     $this -> display();
 }
开发者ID:nicevoice,项目名称:saima_versatil,代码行数:34,代码来源:ShareAction.class.php

示例5: tree

 /**
  * 指定店铺的 商品分类 树
  * @param number $sid		店铺ID
  * @param string $status	状态
  */
 public function tree($sid, $status = null)
 {
     $status_view = array('default' => '所有', 'del' => '已删除', 'forbid' => '禁用', 'allow' => '正常');
     //默认是 所有 未删除
     //店铺id必须有
     $map['store_id'] = (int) $sid;
     if ($map['store_id'] <= 0) {
         $this->error('参数非法');
     }
     $store_M = new Model('Store');
     $store_info = $store_M->find($map['store_id']);
     if (empty($store_info)) {
         $this->error('店铺不存在');
     }
     $this->assign('store_info', $store_info);
     $now_status = $status_view['default'];
     if (isset($status) && key_exists($status, CategoryModel::$mystat)) {
         //指定查询状态
         $map['status'] = CategoryModel::$mystat[$status];
         $now_status = $status_view[$status];
     } else {
         $map['status'] = array('EGT', 0);
         //默认查询状态为未删除的数据
     }
     $model = new CategoryModel();
     $cate_tree = $model->ztreeArr($map);
     $cate_tree = json_encode($cate_tree);
     $this->assign('tree_json', $cate_tree);
     //ztree json
     $this->assign('now_status', $now_status);
     //当前页面筛选的状态
     // 记录当前列表页的cookie
     cookie(C('CURRENT_URL_NAME'), $_SERVER['REQUEST_URI']);
     $this->display();
 }
开发者ID:hcpzhe,项目名称:foodorder,代码行数:40,代码来源:CategoryController.class.php

示例6: startthelog

function startthelog($logname, $quick = FALSE)
{
    logit($logname, '-----------------------------------------------------------');
    $line = '';
    //logit($logname, $_SERVER['HTTP_REFERER']);
    if (!$quick) {
        // doing the dns lookup takes some extra time so use $quick to speed things up a bid
        $line = gethostbyaddr($_SERVER["REMOTE_HOST"]);
        if ($line == $_SERVER["REMOTE_ADDR"]) {
            $line = '** No DNS entry found for calling IP';
        }
        $line = ' - ' . $line;
    }
    logit($logname, $_SERVER["REMOTE_ADDR"] . $line);
    if (key_exists('HTTP_USER_AGENT', $_SERVER)) {
        logit($logname, $_SERVER['HTTP_USER_AGENT'] . $line);
    }
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        if (substr(str_replace(chr(10), '', print_r($_POST, true)), 10) == '') {
            logit($logname, 'Called as a POST, but NO values were passed in');
        } else {
            logit($logname, 'POST values: ' . substr(str_replace(chr(10), '', print_r($_POST, true)), 10));
        }
    }
    if ($_SERVER["QUERY_STRING"] != '') {
        logit($logname, 'GET param string: ' . $_SERVER["QUERY_STRING"]);
    }
}
开发者ID:kyukido22,项目名称:phplib,代码行数:28,代码来源:logitv2.php

示例7: getNavigation

 /**
  * Return all navigation collection
  * 
  * @param type $name
  * @return array
  */
 public function getNavigation($name)
 {
     if (!key_exists($name, $this->_navigations)) {
         return null;
     }
     return $this->_navigations[$name];
 }
开发者ID:zedmaster,项目名称:ticobox,代码行数:13,代码来源:Navigation.php

示例8: AddPreLoadedImage

 public function AddPreLoadedImage($strLoc)
 {
     if (!key_exists(MJaxTouchConfig::preloadImages, $this->arrConfig)) {
         $this->arrConfig[MJaxTouchConfig::preloadImages] = array();
     }
     $this->arrConfig[MJaxTouchConfig::preloadImages][] = $strLoc;
 }
开发者ID:schematical,项目名称:MJax2.0,代码行数:7,代码来源:MJaxTouchConfig.class.php

示例9: save

 public function save()
 {
     $name = basename($this->project->compiledFile, '.chm');
     $dir = dirname($this->project->compiledFile);
     if (!is_dir($dir)) {
         throw new CException(Yii::t('yiiext', 'Directory "{directory} not available.".', array('{directory}' => $dir)));
     }
     if ($this->project->contentsFile === NULL) {
         $this->project->contentsFile = $dir . '/' . $name . '.hhc';
     }
     if ($this->project->indexFile === NULL) {
         $this->project->indexFile = $dir . '/' . $name . '.hhk';
     }
     if ($this->project->path === NULL) {
         $this->project->path = $dir . '/' . $name . '.hhp';
     }
     $windows = $this->project->getWindows();
     if ($this->project->defaultWindow === NULL || !key_exists($this->project->defaultWindow, $windows)) {
         reset($windows);
         $this->project->defaultWindow = current($windows)->id;
     }
     $this->toc->save($this->project->contentsFile);
     $this->index->save($this->project->indexFile);
     $this->project->save($this->project->path);
     // generate project
     $exeFile = dirname(__FILE__) . '/vendors/hhc.exe';
     exec('"' . $exeFile . '" "' . $this->project->path . '"', $output, $return_var);
     if (!file_exists($this->project->compiledFile)) {
         throw new CException(Yii::t('yiiext', 'Cannot save .chm file "{file}".' . "\nReturn: {$return_var}\nOutput:\n" . implode("\n", $output), array('{file}' => $this->project->compiledFile)));
     }
     return $this->project->compiledFile;
 }
开发者ID:sinelnikof,项目名称:yiiext,代码行数:32,代码来源:EChm.php

示例10: setLocation

 /**
  * Sets the value of the location property.
  *
  * You can set the value of this property using a GeoPoint object or using an array,
  *
  * <code>
  * // example with GeoPoint
  * $entity->location = new GeoPoint(-45.123, -23.345);
  *
  * // example with arrays
  * $entity->location = [-45.123, -23.345];
  * $entity->location = ['x' => -45.123, 'y' => -23.345];
  * $entity->location = ['longitude' => -45.123, 'latitude' => -23.345];
  *
  * </code>
  *
  * This method sets the value of the property _geoLocation with a PostGIS ST_Geography type.
  *
  * @param \MapasCulturais\Types\GeoPoint|array $location
  */
 function setLocation($location)
 {
     $x = $y = null;
     if (!$location instanceof GeoPoint) {
         if (is_array($location) && key_exists('x', $location) && key_exists('y', $location)) {
             $x = $location['x'];
             $y = $location['y'];
         } elseif (is_array($location) && key_exists('longitude', $location) && key_exists('latitude', $location)) {
             $x = $location['longitude'];
             $y = $location['latitude'];
         } elseif (is_array($location) && count($location) === 2 && is_numeric($location[0]) && is_numeric($location[1])) {
             $x = $location[0];
             $y = $location[1];
         } else {
             throw new \Exception(App::txt('The location must be an instance of \\MapasCulturais\\Types\\GeoPoint or an array with two numeric values'));
         }
         $location = new GeoPoint($x, $y);
     }
     if (is_numeric($x) && is_numeric($y)) {
         $rsm = new \Doctrine\ORM\Query\ResultSetMapping();
         $sql = "SELECT ST_GeographyFromText('POINT({$location->longitude} {$location->latitude})') AS geo";
         $rsm->addScalarResult('geo', 'geo');
         $query = App::i()->em->createNativeQuery($sql, $rsm);
         $this->_geoLocation = $query->getSingleScalarResult();
     }
     $this->location = $location;
 }
开发者ID:wagnertw,项目名称:mapasculturais,代码行数:47,代码来源:EntityGeoLocation.php

示例11: render

 public static function render($params = [])
 {
     $html = '';
     /** Rendering breadcrumb show */
     if (!empty($params)) {
         foreach ($params as $j => $i) {
             /** Prepping data */
             $r = explode(':', $i);
             /** Rendering breadcrumb list */
             if (!empty(self::$array)) {
                 foreach (self::$array as $k => $v) {
                     if ($k == $r[0]) {
                         if ($j == count($params) - 1) {
                             $html .= '<li><a class="acitve-pages" >' . $v['title'] . '</a></li>';
                         } else {
                             if (key_exists(1, $r)) {
                                 $html .= '<li><a href="' . $v['url'] . '/' . $r[1] . '" >' . $v['title'] . '</a></li>';
                             } else {
                                 $html .= '<li><a href="' . $v['url'] . '" >' . $v['title'] . '</a></li>';
                             }
                         }
                     }
                 }
             }
         }
     }
     $html .= '';
     return $html;
 }
开发者ID:Abdulhmid,项目名称:inventory,代码行数:29,代码来源:Breadcrumb.php

示例12: setDefine

 /**
  * Sets options for dbd.h
  * @param string $define name of contstant to modify
  * @param mixed $value value to set constant to
  * @return boolean
  */
 public function setDefine($define, $value)
 {
     if (key_exists($define, $this->dbdDefines)) {
         /**@TODO: add sanitiy checking for define values */
         switch ($define) {
             /**
              * String values need to be quoted
              */
             case 'HOST':
             case 'BINDHOST':
             case 'EXECPROC_NULL':
             case 'SHARED_SECRET':
             case 'HIGHLIGHT_PREFIX':
             case 'HIGHLIGHT_SUFFIX':
             case 'SEPARATOR_BETWEEN_PREFIX_AND_DATA':
             case 'INSTANCE_SEMAPHORE':
                 $value = "'" . $value . "'";
                 break;
             default:
                 break;
         }
         $this->dbdDefines["{$define}"] = $value;
         return true;
     }
     return false;
 }
开发者ID:AJMartel,项目名称:enc,代码行数:32,代码来源:getdbd.class.php

示例13: run

 public function run()
 {
     $message = '';
     $projectlist = new ProjectListModel();
     $projectlist->read();
     $projectIds = array_map(function ($e) {
         return $e['id'];
     }, $projectlist->entries);
     $emptyQuestionTitles = 0;
     foreach ($projectIds as $projectId) {
         $project = new ProjectModel($projectId);
         $activityEntries = ActivityListDto::getActivityForProject($project);
         foreach ($activityEntries as $activity) {
             if (key_exists('questionRef', $activity) && key_exists('question', $activity['content'])) {
                 $questionId = $activity['questionRef'];
                 $questionTitle = $activity['content']['question'];
                 if ($questionTitle == '') {
                     $emptyQuestionTitles++;
                     $questionModel = new QuestionModel($project, $questionId);
                     $activityModel = new ActivityModel($project, $activity['id']);
                     $newTitle = $questionModel->getTitleForDisplay();
                     $activityModel->actionContent['question'] = $newTitle;
                     $message .= "Fixing activity " . $activity['action'] . " with title '" . $newTitle . "'\n";
                     $activityModel->write();
                 }
             }
         }
     }
     if ($emptyQuestionTitles > 0) {
         $message .= "\n\nFixed up {$emptyQuestionTitles} empty question titles in the activity log\n\n";
     } else {
         $message .= "\n\nNo empty question titles were found in the activity log \n\n";
     }
     return $message;
 }
开发者ID:bbriggs,项目名称:web-languageforge,代码行数:35,代码来源:FixActivityMissingQuestionTitles.php

示例14: stream_read

 function stream_read($count)
 {
     if (key_exists($this->s++, $this->lines)) {
         return $this->lines[$this->s - 1];
     }
     return "";
 }
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:bug60455_03.php

示例15: weekbyhours

 protected function weekbyhours()
 {
     $this->matrix = array();
     foreach ($this->events as $event) {
         $recur = new Recurrences($event);
         foreach ($recur->recurrences as $recurrence) {
             /* @var $recurrence When */
             if ($recurrence->getFequency() == 'WEEKLY') {
                 foreach ($recurrence->getByDay() as $day) {
                     if ($day[0] == '+') {
                         $weekday = substr($day, 2);
                         $start = new \DateTime($event->getStart()->dateTime);
                         $time = $start->format('H:i');
                         if (!key_exists($time, $this->matrix)) {
                             $this->matrix[$time] = array();
                         }
                         $this->matrix[$time][$weekday][] = $event;
                     }
                 }
             }
         }
     }
     ksort($this->matrix);
     return $this->matrix;
 }
开发者ID:bitborder,项目名称:bolt-extension-gapps,代码行数:25,代码来源:EventMatrix.php


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