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


PHP Arrays::first方法代码示例

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


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

示例1: query

 public function query($sql)
 {
     $resource = mssql_query($sql, $this->link);
     if ($resource) {
         if (is_resource($resource)) {
             $i = 0;
             $data = array();
             while ($result = mssql_fetch_assoc($resource)) {
                 $data[$i] = $result;
                 $i++;
             }
             mssql_free_result($resource);
             $query = new Object();
             $row = isset(Arrays::first($data)) ? Arrays::first($data) : array();
             $query->setRow($row)->setRows($data)->setNumRows($i);
             unset($data);
             return $query;
         } else {
             return true;
         }
     } else {
         trigger_error('Error: ' . mssql_get_last_message($this->link) . '<br />' . $sql);
         exit;
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:25,代码来源:Sqlserver.php

示例2: orderBy

 public function orderBy($tab, $fieldOrder, $orderDirection = 'ASC')
 {
     $sortFunc = function ($key, $direction) {
         return function ($a, $b) use($key, $direction) {
             if ('ASC' == $direction) {
                 return $a[$key] > $b[$key];
             } else {
                 return $a[$key] < $b[$key];
             }
         };
     };
     if (Arrays::is($fieldOrder) && !Arrays::is($orderDirection)) {
         $t = array();
         foreach ($fieldOrder as $tmpField) {
             array_push($t, $orderDirection);
         }
         $orderDirection = $t;
     }
     if (!Arrays::is($fieldOrder) && Arrays::is($orderDirection)) {
         $orderDirection = Arrays::first($orderDirection);
     }
     if (Arrays::is($fieldOrder) && Arrays::is($orderDirection)) {
         for ($i = 0; $i < count($fieldOrder); $i++) {
             usort($tab, $sortFunc($fieldOrder[$i], $orderDirection[$i]));
         }
     } else {
         usort($tab, $sortFunc($fieldOrder, $orderDirection));
     }
     return $tab;
 }
开发者ID:schpill,项目名称:standalone,代码行数:30,代码来源:services.php

示例3: connexion

 public static function connexion()
 {
     $args = func_get_args();
     $class = '\\Thin\\Db\\' . ucfirst(Inflector::lower(Arrays::first($args)));
     array_shift($args);
     return call_user_func_array([$class, 'instance'], $args);
 }
开发者ID:schpill,项目名称:thin,代码行数:7,代码来源:Db.php

示例4: __call

 public function __call($func, $argv)
 {
     if (substr($func, 0, 3) == 'get') {
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, 3)));
         $key = Inflector::lower($uncamelizeMethod);
         if (isset($argv[0])) {
             $environment = $argv[0];
         } else {
             $environment = APPLICATION_ENV;
         }
         return getConfig($key, $environment);
     } elseif (substr($func, 0, 3) == 'set') {
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, 3)));
         $key = Inflector::lower($uncamelizeMethod);
         $value = Arrays::first($argv);
         if (isset($argv[1])) {
             $environment = $argv[1];
         } else {
             $environment = 'all';
         }
         setConfig($key, $value, $environment);
         return $this;
     } elseif (substr($func, 0, 3) == 'has') {
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, 3)));
         $key = Inflector::lower($uncamelizeMethod);
         if (isset($argv[0])) {
             $environment = $argv[0];
         } else {
             $environment = APPLICATION_ENV;
         }
         return null !== getConfig($key, $environment);
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:33,代码来源:Configdata.php

示例5: __call

 public function __call($method, $args)
 {
     if (true === $this->__has($method)) {
         return $this->__fire($method, $args);
     }
     $reverse = strrev($method);
     $last = $reverse[0];
     if ('s' == $last) {
         if (!count($args)) {
             return isAke($this->values, $method);
         } else {
             $this->values[$method] = !Arrays::is($this->values[$method]) ? array() : $this->values[$method];
             foreach ($args as $arg) {
                 array_push($this->values[$method], $arg);
             }
         }
         return $this;
     } else {
         $method .= 's';
         if (!count($args)) {
             $val = isAke($this->values, $method);
             return count($val) ? Arrays::first($val) : null;
         } else {
             $this->values[$method] = !Arrays::is($this->values[$method]) ? array() : $this->values[$method];
             foreach ($args as $arg) {
                 array_push($this->values[$method], $arg);
             }
         }
         return $this;
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:31,代码来源:Conf.php

示例6: __call

 public function __call($method, $args)
 {
     if (0 == count($args)) {
         return static::get($method);
     } elseif (1 == count($args)) {
         return static::set($method, Arrays::first($args));
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:8,代码来源:Flash.php

示例7: send

 public static function send($arguments = array())
 {
     $response = static::request('messages/send', $arguments);
     if (false !== $response && Arrays::is($response)) {
         $response = Arrays::first($response);
         return $response['status'] == 'sent' ? true : $response['status'];
     }
     return false;
 }
开发者ID:noikiy,项目名称:inovi,代码行数:9,代码来源:Mandrill.php

示例8: del

 public function del($key)
 {
     $files = $this->search($key . '#');
     if (count($files)) {
         $key = Arrays::first($files);
         unset($this->buffer[$key]);
         $this->commit();
     }
     return $this;
 }
开发者ID:schpill,项目名称:thin,代码行数:10,代码来源:Speedb.php

示例9: del

 public function del($key)
 {
     $pattern = strstr($key, '#') ? $key : $key . '#';
     $rows = $this->search($pattern);
     if (count($rows)) {
         $key = Arrays::first($rows);
         $this->db->srem($this->ns, $key);
     }
     return $this;
 }
开发者ID:schpill,项目名称:thin,代码行数:10,代码来源:Quickdb.php

示例10: __construct

 public function __construct($args)
 {
     $method = Arrays::first($args);
     $argv = array_slice($args, 1);
     if (method_exists($this, $method)) {
         call_user_func_array(array($this, $method), $argv);
     } else {
         $this->render(Arrays::first($args) . ' is not a valid method', 'ERROR');
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:10,代码来源:Cli.php

示例11: __callStatic

 public static function __callStatic($method, $args)
 {
     $auth = ['GET', 'POST', 'COOKIE', 'SESSION', 'SERVER', 'REQUEST', 'GLOBALS'];
     $method = Inflector::upper($method);
     if (Arrays::in($method, $auth) && count($args) > 0) {
         $default = isset($args[1]) ? $args[1] : null;
         return isAke(self::tab($method), Arrays::first($args), $default);
     } elseif (Arrays::in($method, $auth) && count($args) == 0) {
         return self::tab($method);
     } else {
         throw new Exception("Wrong parameters.");
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:13,代码来源:Input.php

示例12: __call

 public function __call($func, $argv)
 {
     if (substr($func, 0, 3) == 'get') {
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, 3)));
         $key = Inflector::lower($uncamelizeMethod);
         return getMeta($key);
     } elseif (substr($func, 0, 3) == 'set') {
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, 3)));
         $key = Inflector::lower($uncamelizeMethod);
         $value = Arrays::first($argv);
         setMeta($key, $value);
         return $this;
     } elseif (substr($func, 0, 3) == 'has') {
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, 3)));
         $key = Inflector::lower($uncamelizeMethod);
         return null !== getMeta($key);
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:18,代码来源:Metadata.php

示例13: __callStatic

 public static function __callStatic($method, $args)
 {
     $db = Inflector::uncamelize($method);
     if (fnmatch('*_*', $db)) {
         list($database, $table) = explode('_', $db, 2);
     } else {
         $database = SITE_NAME;
         $table = $db;
     }
     if (!count($args)) {
         return Moo\Db::instance($database, $table);
     } elseif (count($args) == 1) {
         $id = Arrays::first($args);
         if (is_numeric($id)) {
             return Moo\Db::instance($database, $table)->find($id);
         }
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:18,代码来源:Moo.php

示例14: __match

 /**
  * @param array $patterns
  * @return \Closure
  */
 protected static function __match(array $patterns)
 {
     return function (...$args) use($patterns) {
         // [a] -> Bool
         $patternApplies = function ($pattern) use($args) {
             /** @noinspection PhpParamsInspection */
             return Logic::all(Arrays::zipWith(Lambda::apply(), Arrays::map(self::make(), Arrays::init($pattern)), $args));
         };
         try {
             /** @noinspection PhpParamsInspection */
             $getMatchedImplementation = Lambda::compose(Arrays::last(), Arrays::first($patternApplies), Arrays::filter(function ($pattern) use($args) {
                 return count($pattern) - 1 === count($args);
             }));
             return call_user_func_array($getMatchedImplementation($patterns), $args);
         } catch (\Exception $e) {
             throw new IncompletePatternMatchException('Incomplete pattern match expression.');
         }
     };
 }
开发者ID:joseph-walker,项目名称:vector,代码行数:23,代码来源:Pattern.php

示例15: clean

 private function clean($key, $force = false)
 {
     $now = time();
     $file = $this->getFile('expires.' . $key . '.5');
     $path = str_replace(DS . Arrays::last(explode(DS, $file)), '', $file);
     if (is_dir($path)) {
         $files = glob($path . DS . '*.php');
         if (!empty($files)) {
             $when = (int) str_replace([$path . DS, '.php'], '', Arrays::first($files));
             if ($when < $now || true === $force) {
                 File::rmdir($path);
                 $this->remove($key);
             }
         }
     } else {
         if (true === $force) {
             $this->remove($key);
         }
     }
     return $this;
 }
开发者ID:schpill,项目名称:standalone,代码行数:21,代码来源:cache.php


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