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


PHP key函数代码示例

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


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

示例1: calculateGFRResult

 function calculateGFRResult()
 {
     $tmpArr = array();
     $tmpArr[] = date('Y-m-d H:i:s');
     //observation time
     $tmpArr[] = 'GFR (CALC)';
     //desc
     $gender = NSDR::populate($this->_patientId . "::com.clearhealth.person.displayGender");
     $crea = NSDR::populate($this->_patientId . "::com.clearhealth.labResults[populate(@description=CREA)]");
     $genderFactor = null;
     $creaValue = null;
     $personAge = null;
     $raceFactor = 1;
     switch ($gender[key($gender)]) {
         case 'M':
             $genderFactor = 1;
             break;
         case 'F':
             $genderFactor = 0.742;
             break;
     }
     if ((int) strtotime($crea['observation_time']) >= strtotime('now - 60 days') && strtolower($crea[key($crea)]['units']) == 'mg/dl') {
         $creaValue = $crea[key($crea)]['value'];
     }
     $person = new Person();
     $person->personId = $this->_patientId;
     $person->populate();
     if ($person->age > 0) {
         $personAge = $person->age;
     }
     $personStat = new PatientStatistics();
     $personStat->personId = $this->_patientId;
     $personStat->populate();
     if ($personStat->race == "AFAM") {
         $raceFactor = 1.21;
     }
     $gfrValue = "INC";
     if ($personAge > 0 && $creaValue > 0) {
         $gfrValue = "" . (int) round(pow($creaValue, -1.154) * pow($personAge, -0.203) * $genderFactor * $raceFactor * 186);
     }
     trigger_error("gfr:: " . $gfrValue, E_USER_NOTICE);
     $tmpArr[] = $gfrValue;
     // lab value
     $tmpArr[] = 'mL/min/1.73 m2';
     //units
     $tmpArr[] = '';
     //ref range
     $tmpArr[] = '';
     //abnormal
     $tmpArr[] = 'F';
     //status
     $tmpArr[] = date('Y-m-d H:i:s') . '::' . '0';
     // observationTime::(boolean)normal; 0 = abnormal, 1 = normal
     $tmpArr[] = '0';
     //sign
     //$this->_calcLabResults[uniqid()] = $tmpArr;
     $this->_calcLabResults[1] = $tmpArr;
     // temporarily set index to one(1) to be able to include in selected lab results
     return $tmpArr;
 }
开发者ID:dragonlet,项目名称:clearhealth,代码行数:60,代码来源:CalcLabs.php

示例2: prepare_form

 /**
  * {@inheritdoc}
  */
 public function prepare_form($request, $template, $user, $row, &$error)
 {
     $avatar_list = $this->get_avatar_list($user);
     $category = $request->variable('avatar_local_cat', key($avatar_list));
     foreach ($avatar_list as $cat => $null) {
         if (!empty($avatar_list[$cat])) {
             $template->assign_block_vars('avatar_local_cats', array('NAME' => $cat, 'SELECTED' => $cat == $category));
         }
         if ($cat != $category) {
             unset($avatar_list[$cat]);
         }
     }
     if (!empty($avatar_list[$category])) {
         $template->assign_vars(array('AVATAR_LOCAL_SHOW' => true));
         $table_cols = isset($row['avatar_gallery_cols']) ? $row['avatar_gallery_cols'] : 4;
         $row_count = $col_count = $avatar_pos = 0;
         $avatar_count = sizeof($avatar_list[$category]);
         reset($avatar_list[$category]);
         while ($avatar_pos < $avatar_count) {
             $img = current($avatar_list[$category]);
             next($avatar_list[$category]);
             if ($col_count == 0) {
                 ++$row_count;
                 $template->assign_block_vars('avatar_local_row', array());
             }
             $template->assign_block_vars('avatar_local_row.avatar_local_col', array('AVATAR_IMAGE' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $img['file'], 'AVATAR_NAME' => $img['name'], 'AVATAR_FILE' => $img['filename'], 'CHECKED' => $img['file'] === $row['avatar']));
             $template->assign_block_vars('avatar_local_row.avatar_local_option', array('AVATAR_FILE' => $img['filename'], 'S_OPTIONS_AVATAR' => $img['filename'], 'CHECKED' => $img['file'] === $row['avatar']));
             $col_count = ($col_count + 1) % $table_cols;
             ++$avatar_pos;
         }
     }
     return true;
 }
开发者ID:WarriorMachines,项目名称:warriormachines-phpbb,代码行数:36,代码来源:local.php

示例3: validatePartial

 /**
  * Validates a partial array. Some data may be missing from the given $array, then it will be taken from the
  * full array.
  *
  * Since the array can be incomplete, this method does not validate required parameters.
  *
  * @param array $array
  * @param array $fullArray
  *
  * @return bool
  */
 public function validatePartial(array $array, array $fullArray)
 {
     $unvalidatedFields = array_flip(array_keys($array));
     // field validators
     foreach ($this->validators as $field => $validator) {
         unset($unvalidatedFields[$field]);
         // if the value is present
         if (isset($array[$field])) {
             // validate it if a validator is given, skip it otherwise
             if ($validator && !$validator->validate($array[$field])) {
                 $this->setError($validator->getError());
                 return false;
             }
         }
     }
     // check if any unsupported fields remain
     if ($unvalidatedFields) {
         reset($unvalidatedFields);
         $field = key($unvalidatedFields);
         $this->error($this->messageUnsupported, $field);
         return false;
     }
     // post validators
     foreach ($this->postValidators as $validator) {
         if (!$validator->validatePartial($array, $fullArray)) {
             $this->setError($validator->getError());
             return false;
         }
     }
     return true;
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:42,代码来源:CPartialSchemaValidator.php

示例4: foo

function foo(&$state)
{
    $contentDict = end($state);
    for ($contentDict = end($state); $contentDict !== false; $contentDict = prev($state)) {
        echo key($state) . " => " . current($state) . "\n";
    }
}
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:bug35022.php

示例5: projectImport

 public function projectImport($api, $args)
 {
     $this->checkACL($api, $args);
     $this->requireArgs($args, array('module'));
     $bean = BeanFactory::getBean($args['module']);
     if (!$bean->ACLAccess('save') || !$bean->ACLAccess('import')) {
         throw new SugarApiExceptionNotAuthorized('EXCEPTION_NOT_AUTHORIZED');
     }
     if (isset($_FILES) && count($_FILES) === 1) {
         reset($_FILES);
         $first_key = key($_FILES);
         if (isset($_FILES[$first_key]['tmp_name']) && $this->isUploadedFile($_FILES[$first_key]['tmp_name']) && isset($_FILES[$first_key]['size']) && isset($_FILES[$first_key]['size']) > 0) {
             try {
                 $importerObject = new PMSEProjectImporter();
                 $name = $_FILES[$first_key]['name'];
                 $extension = pathinfo($name, PATHINFO_EXTENSION);
                 if ($extension == $importerObject->getExtension()) {
                     $data = $importerObject->importProject($_FILES[$first_key]['tmp_name']);
                     $results = array('project_import' => $data);
                 } else {
                     throw new SugarApiExceptionRequestMethodFailure('ERROR_UPLOAD_FAILED');
                 }
             } catch (SugarApiExceptionNotAuthorized $e) {
                 throw new SugarApiExceptionNotAuthorized('ERROR_UPLOAD_ACCESS_PD');
             } catch (Exception $e) {
                 throw new SugarApiExceptionRequestMethodFailure('ERROR_UPLOAD_FAILED');
             }
             return $results;
         }
     } else {
         throw new SugarApiExceptionMissingParameter('ERROR_UPLOAD_FAILED');
     }
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:33,代码来源:PMSEProjectImportExportApi.php

示例6: getFilteredWords

function getFilteredWords()
{
    global $Weblogs;
    if (file_exists('db/search/filtered_words.txt')) {
        $filtered_file = file('db/search/filtered_words.txt');
        foreach ($filtered_file as $val) {
            if (substr($val, 0, 2) !== "//") {
                $filtered_words[] = trim($val);
            }
        }
    } else {
        $filtered_words = array();
    }
    @reset($Weblogs);
    @($Current_weblog = key($Weblogs));
    $theLang = $Weblogs[$Current_weblog]['language'];
    if ('' != $theLang && file_exists('db/search/filtered_words_' . $theLang . '.txt')) {
        // echo '*' ;
        $filtered_file = file('db/search/filtered_words_' . $theLang . '.txt');
        foreach ($filtered_file as $val) {
            $filtered_words[] = trim($val);
        }
    }
    return $filtered_words;
}
开发者ID:wborbajr,项目名称:TecnodataApp,代码行数:25,代码来源:module_lang.php

示例7: setUserEntityTheme

 public function setUserEntityTheme($file, $dataarr)
 {
     $getpersonalcount = DB::table('tbl_bankaccounts')->leftjoin('tbl_bankbranches', 'bankaccount_branch', '=', 'branch_id')->leftjoin('tbl_banks', 'branch_bankid', '=', 'bank_id')->where('bank_isproduct', '0')->where('bankaccount_userentity', 'Personal')->where('bankaccount_createdby', Auth::user()->id)->count();
     $getbusinesscount = DB::table('tbl_bankaccounts')->leftjoin('tbl_bankbranches', 'bankaccount_branch', '=', 'branch_id')->leftjoin('tbl_banks', 'branch_bankid', '=', 'bank_id')->where('bank_isproduct', '0')->where('bankaccount_userentity', 'Business')->where('bankaccount_createdby', Auth::user()->id)->count();
     $resultbViewAcctype = DB::table('tbl_bankaccounttypes')->get();
     $resultbViewAcctypearr = array();
     foreach ($resultbViewAcctype as $data) {
         $resultbViewAcctypearr[$data->accounttype_id] = $data->accounttype_name;
     }
     $resultbViewBanks = DB::table('tbl_banks')->where('bank_isproduct', 0)->where('bank_status', '1')->orderBy('bank_name', 'ASC')->get();
     $resultbViewBanksarr = array();
     foreach ($resultbViewBanks as $data) {
         $resultbViewBanksarr[$data->bank_id] = $data->bank_name;
     }
     $resultbViewBankbranchs = DB::table('tbl_bankbranches')->where("branch_bankid", key($resultbViewBanksarr))->where("branch_status", "1")->get();
     $resultbViewBankBrancharr = array();
     foreach ($resultbViewBankbranchs as $data) {
         $resultbViewBankBrancharr[$data->branch_id] = $data->branch_name;
     }
     if ($getpersonalcount <= 0 and $getbusinesscount <= 0) {
         $data = array('bankaccttype' => $resultbViewAcctypearr, 'bankname' => $resultbViewBanksarr, 'bankbranch' => $resultbViewBankBrancharr);
         $MyTheme = Theme::uses('fonebayad')->layout('ezibills_9_0');
         return $MyTheme->of('registration.firstloginaddbankacct', $data)->render();
     } else {
         //            $MyTheme = Theme::uses('fonebayad')->layout('ezibills_9_0');
         $MyTheme = Theme::uses('fonebayad')->layout('newDefault_myBills');
         return $MyTheme->of($file, $dataarr)->render();
     }
 }
开发者ID:bokbok123,项目名称:ORS,代码行数:29,代码来源:GlobalController.php

示例8: render

 /**
  * Executes parent method parent::render(), creates deliveryset category tree,
  * passes data to Smarty engine and returns name of template file "deliveryset_main.tpl".
  *
  * @return string
  */
 public function render()
 {
     $myConfig = $this->getConfig();
     parent::render();
     $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
     if ($soxId != "-1" && isset($soxId)) {
         // load object
         $odeliveryset = oxNew("oxdeliveryset");
         $odeliveryset->loadInLang($this->_iEditLang, $soxId);
         $oOtherLang = $odeliveryset->getAvailableInLangs();
         if (!isset($oOtherLang[$this->_iEditLang])) {
             // echo "language entry doesn't exist! using: ".key($oOtherLang);
             $odeliveryset->loadInLang(key($oOtherLang), $soxId);
         }
         $this->_aViewData["edit"] = $odeliveryset;
         // remove already created languages
         $aLang = array_diff(oxLang::getInstance()->getLanguageNames(), $oOtherLang);
         if (count($aLang)) {
             $this->_aViewData["posslang"] = $aLang;
         }
         foreach ($oOtherLang as $id => $language) {
             $oLang = new oxStdClass();
             $oLang->sLangDesc = $language;
             $oLang->selected = $id == $this->_iEditLang;
             $this->_aViewData["otherlang"][$id] = clone $oLang;
         }
     }
     if (oxConfig::getParameter("aoc")) {
         $aColumns = array();
         include_once 'inc/' . strtolower(__CLASS__) . '.inc.php';
         $this->_aViewData['oxajax'] = $aColumns;
         return "popups/deliveryset_main.tpl";
     }
     return "deliveryset_main.tpl";
 }
开发者ID:JulianaSchuster,项目名称:oxid-frontend,代码行数:41,代码来源:deliveryset_main.php

示例9: getTypeName

function getTypeName($val, $argument = null)
{
    $type = gettype($val);
    global $detectDateMode;
    switch ($type) {
        case "string":
            if ($detectDateMode == 1 && isDate($val)) {
                return "Date";
            } else {
                if ($detectDateMode == 2 && (bool) strtotime($val)) {
                    return "Date";
                } else {
                    return "String";
                }
            }
        case "integer":
            return "int";
        case "double":
            return "float";
        case "boolean":
            return "boolean";
        case "array":
            if (is_numeric(key($val))) {
                return "RealmList<" . $argument . ">";
            } else {
                return $argument;
            }
    }
    return null;
}
开发者ID:tomasz-m,项目名称:realmGenerator,代码行数:30,代码来源:processor.php

示例10: edit

 /**
  * Edit a blog.
  *
  * @param string $id
  *
  * @return Response
  */
 public function edit($id)
 {
     $blog = Blog::find($id);
     $file_size = key(config('image.image_sizes'));
     $files = $this->getFiles('images/blogs/' . $blog->id . '/' . $file_size);
     return view('admin/blog/edit', ['blog' => $blog, 'files' => $files, 'file_size' => $file_size]);
 }
开发者ID:kudosagency,项目名称:kudos-php,代码行数:14,代码来源:BlogController.php

示例11: printShort

 /**
  * Print a concise, human readable representation of a value.
  *
  * @param wild Any value.
  * @return string Human-readable short representation of the value.
  * @task print
  */
 public static function printShort($value)
 {
     if (is_object($value)) {
         return 'Object ' . get_class($value);
     } else {
         if (is_array($value)) {
             $str = 'Array ';
             if ($value) {
                 if (count($value) > 1) {
                     $str .= 'of size ' . count($value) . ' starting with: ';
                 }
                 reset($value);
                 // Prevent key() from giving warning message in HPHP.
                 $str .= '{ ' . self::printShort(key($value)) . ' => ' . self::printShort(head($value)) . ' }';
             }
             return $str;
         } else {
             // NOTE: Avoid PhutilUTF8StringTruncator here since the data may not be
             // UTF8 anyway, it's slow for large inputs, and it might not be loaded
             // yet.
             $limit = 1024;
             $str = self::printableValue($value);
             if (strlen($str) > $limit) {
                 if (is_string($value)) {
                     $str = "'" . substr($str, 1, $limit) . "...'";
                 } else {
                     $str = substr($str, 0, $limit) . '...';
                 }
             }
             return $str;
         }
     }
 }
开发者ID:barcelonascience,项目名称:libphutil,代码行数:40,代码来源:PhutilReadableSerializer.php

示例12: finalize

 function finalize()
 {
     // get parent's output
     parent::finalize();
     $output = parent::getOutput();
     $tex_output = '';
     foreach ($output as $token) {
         if ($this->_enumerated) {
             $class = $token[0];
             $content = $token[1];
         } else {
             $key = key($token);
             $class = $key;
             $content = $token[$key];
         }
         $iswhitespace = ctype_space($content);
         if (!$iswhitespace) {
             if ($class === 'special') {
                 $class = 'code';
             }
             $tex_output .= sprintf('\\textcolor{%s}{%s}', $class, $this->escape($content));
         } else {
             $tex_output .= $content;
         }
     }
     $this->_output = "\\begin{alltt}\n" . $tex_output . "\\end{alltt}";
 }
开发者ID:super-d2,项目名称:codeigniter_demo,代码行数:27,代码来源:MarkdownHtml2Tex.php

示例13: convert

 /**
  * @param mixed $item
  * @return mixed
  * @throws \Exception
  */
 public function convert($item)
 {
     foreach ($this->processors as $field => $actions) {
         // If field doesn't exist:
         // - Create new column with null value
         // - Add new route to this column
         if (!array_key_exists($field, $item)) {
             $item[$field] = null;
             $this->route[$field] = $field;
         }
         // An array of actions has been given
         if (is_array($actions) && count($actions) > 0) {
             foreach ($actions as $action) {
                 // Get action name and options
                 $name = is_array($action) ? key($action) : $action;
                 $options = is_array($action) ? current($action) : null;
                 // Set processor name in CamelCase
                 $name = implode('', array_map('ucwords', explode('_', $name)));
                 // Get processor class from action name
                 $class = 'Stratis\\Component\\Migrator\\Processor\\' . $name . 'Processor';
                 // Check if class exists
                 if (!class_exists($class)) {
                     throw new \Exception($class . ' does not exists');
                 }
                 // Use processor exec function
                 $item[$field] = $class::exec($item[$field], $options, $item);
             }
         }
     }
     return $item;
 }
开发者ID:AgenceStratis,项目名称:migrator,代码行数:36,代码来源:Processor.php

示例14: saveArrayToXml

 /**
  * Generates Xml of Array
  * @param string $rootName [optional] default 'root'
  * @return String xml string if available otherwise false
  */
 public function saveArrayToXml($rootName = "")
 {
     $this->document = new Uni_Data_XDOMDocument();
     $arr = array();
     if (count($this->_xmlArray) > 1) {
         if ($rootName != "") {
             $root = $this->document->createElement($rootName);
         } else {
             $root = $this->document->createElement("root");
         }
         $arr = $this->_xmlArray;
     } else {
         $key = key($this->_xmlArray);
         if (!is_int($key)) {
             $root = $this->document->createElement($key);
         } else {
             if ($rootName != "") {
                 $root = $this->document->createElement($rootName);
             } else {
                 $root = $this->document->createElement("root");
             }
         }
         $arr = $this->_xmlArray[$key];
     }
     $root = $this->document->appendchild($root);
     $this->addArray($arr, $root);
     if ($xmlString = $this->document->saveXML()) {
         return $xmlString;
     } else {
         return false;
     }
 }
开发者ID:UnicodeSystems-PrivateLimited,项目名称:Zendfox,代码行数:37,代码来源:ConvertArrayToXml.php

示例15: processView

 function processView()
 {
     $params = array();
     if (!empty($_REQUEST['name'])) {
         $GLOBALS['system']->includeDBClass('person');
         $this->_person_data = Person::getPersonsByName($_REQUEST['name']);
     } else {
         foreach ($this->_search_terms as $term) {
             if (!empty($_REQUEST[$term])) {
                 $params[$term] = $_REQUEST[$term];
             }
         }
         if (!empty($params)) {
             $this->_person_data = $GLOBALS['system']->getDBObjectData('person', $params, 'AND', 'last_name');
         }
     }
     if (count($this->_person_data) == 1) {
         add_message('One matching person found');
         redirect('persons', array('name' => NULL, 'personid' => key($this->_person_data)));
     }
     $archiveds = array();
     foreach ($this->_person_data as $k => $v) {
         if ($v['status'] == 'archived') {
             $archiveds[$k] = $v;
             unset($this->_person_data[$k]);
         }
     }
     foreach ($archiveds as $k => $v) {
         $this->_person_data[$k] = $v;
     }
 }
开发者ID:vanoudt,项目名称:jethro-pmm,代码行数:31,代码来源:view_3_persons__2_search.class.php


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