本文整理汇总了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;
}
}
示例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;
}
示例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);
}
示例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);
}
}
示例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;
}
}
示例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));
}
}
示例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;
}
示例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;
}
示例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;
}
示例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');
}
}
示例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.");
}
}
示例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);
}
}
示例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);
}
}
}
示例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.');
}
};
}
示例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;
}