本文整理汇总了PHP中arr::c方法的典型用法代码示例。如果您正苦于以下问题:PHP arr::c方法的具体用法?PHP arr::c怎么用?PHP arr::c使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arr
的用法示例。
在下文中一共展示了arr::c方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: trigger
/**
* Throws a new 404 exception.
*
* @throws Eight_Exception_404
* @return void
*/
public static function trigger($page = NULL)
{
// Silence 404 errors (as matched within the ignore array) and die quietly
if (in_array(Router::$complete_uri, arr::c(Eight::config('core.ignore_page_not_found')))) {
Eight::shutdown();
exit;
}
throw new Eight_Exception_404($page);
}
示例2: exists
/**
* Finds an array of files matching the given id or tag.
*
* @param string cache key or tag
* @param bool search for tags
* @return array of filenames matching the id or tag
*/
public function exists($keys, $tag = NO)
{
if ($keys === YES) {
// Find all the files
return glob($this->config['directory'] . '*~*~*');
} elseif ($tag === YES) {
// Find all the files that have the tag name
$paths = array();
foreach ((array) $keys as $tag) {
$paths = array_merge($paths, glob($this->config['directory'] . '*~*' . $tag . '*~*'));
}
// Find all tags matching the given tag
$files = array();
foreach ($paths as $path) {
// Split the files
$tags = explode('~', basename($path));
// Find valid tags
if (count($tags) !== 3 or empty($tags[1])) {
continue;
}
// Split the tags by plus signs, used to separate tags
$item_tags = explode('+', $tags[1]);
// Check each supplied tag, and match aginst the tags on each item.
foreach ($keys as $tag) {
if (in_array($tag, $item_tags)) {
// Add the file to the array, it has the requested tag
$files[] = $path;
}
}
}
return $files;
} else {
$paths = array();
foreach ((array) $keys as $key) {
// Find the file matching the given key
$paths = array_merge($paths, arr::c(glob($this->config['directory'] . str_replace(array('/', '\\', ' '), '_', $key) . '~*')));
}
return $paths;
}
}
示例3: has_role
/**
* Checks for the specified role
*
* @param string role to check for
* @return boolean does the user have this role?
*/
public function has_role($role)
{
if (!$this->loaded) {
return false;
}
if (!is_array($this->roles) or $this->roles === NULL) {
self::db()->use_master(YES);
$rs = self::db()->join('user_roles AS ur', 'ur.user_role_role_id = r.role_id', 'LEFT')->where('ur.user_role_user_id', $this->id)->get('roles AS r')->result_array();
foreach (arr::c($rs) as $r) {
$this->roles[$r['role_id']] = $r['role_name'];
}
unset($r, $rs);
}
// After we loaded them...if we still have no roles
if (!is_array($this->roles) or count($this->roles) == 0) {
return false;
}
if (is_string($role) and !ctype_digit($role)) {
return in_array($role, $this->roles);
} else {
return isset($this->roles[$role]);
}
}
示例4: __to_assoc
public function __to_assoc()
{
$assoc = array();
foreach (arr::c($this->data) as $key => $val) {
$key = str_replace($this->column_prefix, "", $key);
$assoc[$key] = $val;
}
return $assoc;
}
示例5: show_404
/**
* Displays a 404 page, unless config says to ignore page not found.
*
* @param string URI of page
* @param string custom template
* @throws Eight_Exception_404
*/
public static function show_404($page = NO, $template = NO)
{
if (in_array($page, arr::c(Eight::config('core.ignore_page_not_found')))) {
return FALSE;
}
throw new Eight_Exception_404($page, $template);
}
示例6: errors
/**
* Return the errors array.
*
* @param boolean load errors from a lang file
* @return array
*/
public function errors($file = nil, $seperator = false)
{
if ($file === nil) {
return $this->errors;
} else {
$errors = array();
foreach ($this->errors as $input => $error) {
// Key for this input error
$key = "{$file}.{$input}.{$error}";
if (($errors[$input] = Eight::lang($key)) === $key) {
// Get the default error message
$errors[$input] = Eight::lang("{$file}.{$input}.default");
}
}
if (!$seperator) {
return $errors;
} else {
$string = '';
$seperator = is_bool($seperator) ? "<br />\n" : $seperator . "\n";
foreach (arr::c($errors) as $error) {
$string .= $error . $seperator;
}
return $string;
}
}
}