本文整理汇总了PHP中array_empty函数的典型用法代码示例。如果您正苦于以下问题:PHP array_empty函数的具体用法?PHP array_empty怎么用?PHP array_empty使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了array_empty函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testArrayEmpty
/**
* Test recursively if an array is empty
*/
public function testArrayEmpty()
{
$array1 = ['fii' => 3, 'faa' => 2, 'foo' => 1];
$array2 = [];
$array3 = ['fee' => false, 'foo' => ['faa' => ['fii' => 0]], 'fuu' => 0];
$array4 = ['fee' => false, 'foo' => ['faa' => ['fii' => 1]], 'fuu' => 0];
$this->assertEquals(array_empty($array1), false);
$this->assertEquals(array_empty($array2), true);
$this->assertEquals(array_empty($array3), true);
$this->assertEquals(array_empty($array4), false);
}
示例2: __construct
/**
* public function Page( $url = NULL )
*
* Parses through url and returns the path and query contained, also sets up Db and Sql Classes.
*
* @return void
* @author Katalyst Canada
**/
public function __construct($url = NULL)
{
$url = $url == NULL ? $_SERVER['REQUEST_URI'] : $url;
$url = parse_url(trim($url, '#'));
$this->pg["path"] = explode("/", trim($url['path'], '/'));
$this->pg["path"] = array_empty($this->pg["path"]) ? array() : $this->pg["path"];
$this->pg["get"] = isset($url['query']) ? $url['query'] : NULL;
// Set _post, _get, and _path for sharing..
$this->V->_post = $_POST;
$this->V->_get = $_GET;
$this->V->_path = $this->pg['path'];
}
示例3: array_empty
/**
* Test recursively if an array is empty
*
* @param array $array
*
* @return bool
*/
function array_empty(array $array)
{
$bool = true;
foreach ($array as $key => $value) {
if (is_array($value)) {
$bool = array_empty($value);
} else {
if (!empty($value)) {
$bool = false;
}
}
}
return $bool;
}
示例4: wpsight_get_option
function wpsight_get_option($name, $default = false)
{
$options = get_option(WPSIGHT_DOMAIN);
// Get std value if default set TRUE and no options set
if ($default === true && (empty($options[$name]) || array_empty($options[$name]))) {
require_once WPSIGHT_ADMIN_DIR . '/options.php';
$options = wpsight_options();
if (!empty($options[$name]['std'])) {
return $options[$name]['std'];
}
}
if (array_empty($options)) {
return $default;
}
if (isset($options[$name])) {
return $options[$name];
}
return $default;
}
示例5: array_empty
/**
* Check if an array is empty
*
* @return void
* @author Tyler Diaz
**/
function array_empty($mixed)
{
if (is_array($mixed)) {
foreach ($mixed as $value) {
if (!array_empty($value)) {
return false;
}
}
} elseif (!empty($mixed)) {
return false;
}
return true;
}
示例6: home
public function home()
{
global $user;
$v = $this->__(w('f e'));
if (array_empty($v)) {
_fatal();
}
$location = './style/' . $v['e'] . '/';
$filename = _filename($v['f'], $v['e']);
if (!@is_dir($location)) {
_fatal();
}
if ($v['e'] == 'css' && $v['f'] != 'default') {
$v['field'] = !is_numb($v['f']) ? 'alias' : 'id';
$sql = 'SELECT *
FROM _tree
WHERE tree_?? = ?
LIMIT 1';
if (!($tree = _fieldrow(sql_filter($sql, $v['field'], $v['f'])))) {
_fatal();
}
$filetree = _rewrite($tree);
$filename = _filename('_tree_' . $filetree, $v['e']);
}
// 304 Not modified response header
if (@file_exists($location . $filename)) {
$f_last_modified = gmdate('D, d M Y H:i:s', filemtime($location . $filename)) . ' GMT';
$http_if_none_match = v_server('HTTP_IF_NONE_MATCH');
$http_if_modified_since = v_server('HTTP_IF_MODIFIED_SINCE');
header('Last-Modified: ' . $f_last_modified);
if ($f_last_modified == $http_if_modified_since) {
header('HTTP/1.0 304 Not Modified');
header('Content-Length: 0');
exit;
}
}
switch ($v['e']) {
case 'css':
if ($v['f'] != 'default') {
$filetree = _rewrite($tree);
$filename = _filename('_tree_' . $filetree, $v['e']);
if (!@file_exists($location . $filename)) {
_fatal();
}
}
$browser = _browser();
if (f($browser['browser'])) {
$custom = array($browser['browser'] . '-' . $browser['version'], $browser['browser']);
foreach ($custom as $row) {
$handler = _filename('_tree_' . $row, 'css');
if (@file_exists($location . $handler)) {
_style('includes', array('CSS' => _style_handler('css/' . $handler)));
}
}
}
break;
case 'js':
if (!@file_exists($location . $filename)) {
_fatal();
}
_style_vreplace(false);
break;
}
v_style(array('SPATH' => LIBD . 'visual'));
sql_close();
$ext = _style_handler($v['e'] . '/' . $filename);
switch ($v['e']) {
case 'css':
$content_type = 'text/css; charset=utf-8';
$ext = preg_replace('#(border-radius\\-?.*?)\\: ?(([0-9]+)px;)#is', _browser('firefox') || _browser('namoroka') ? '-moz-\\1: \\2' : '', $ext);
$ext = preg_replace('/(#([0-9A-Fa-f]{3})\\b)/i', '#\\2\\2', $ext);
$ext = preg_replace('#\\/\\*(.*?)\\*\\/#is', '', $ext);
$ext = str_replace(array("\r\n", "\n", "\t"), '', $ext);
break;
case 'js':
$content_type = 'application/x-javascript';
require_once XFS . 'core/jsmin.php';
$ext = JSMin::minify($ext);
break;
}
ob_start('ob_gzhandler');
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 60 * 60 * 24 * 30) . ' GMT');
header('Content-type: ' . $content_type);
echo $ext;
exit;
}
示例7: sid_new
/**
* Creates a new session.
*
* If cookies are disabled the page will be reloaded with session id added to query string.
*
* @param boolean Set to true if this function is called from sid_load()
* @return object Data of the user who is calling this script
*/
function sid_new()
{
global $config, $db, $gpc;
if (!$this->sidload && !array_empty($this->cookiedata)) {
$load = $db->query('SELECT mid FROM ' . $db->pre . 'session WHERE mid = "' . $this->cookiedata[0] . '" LIMIT 1', __LINE__, __FILE__);
if ($db->num_rows($load) == 1) {
$this->sidload = true;
$my = $this->sid_load();
return $my;
}
}
if (!array_empty($this->cookiedata)) {
$result = $db->query('SELECT u.*, f.* FROM ' . $db->pre . 'user AS u LEFT JOIN ' . $db->pre . 'userfields as f ON f.ufid = u.id WHERE u.id = "' . $this->cookiedata[0] . '" AND u.pw = "' . $this->cookiedata[1] . '" LIMIT 1', __LINE__, __FILE__);
$my = $gpc->prepare($db->fetch_object($result));
$nodata = $db->num_rows($result) == 1 ? false : true;
} else {
$nodata = true;
}
if ($nodata == false && $my->confirm == '11') {
$id =& $my->id;
$lastvisit =& $my->lastvisit;
$my->clv = $my->lastvisit;
$my->vlogin = true;
makecookie($config['cookie_prefix'] . '_vdata', $my->id . "|" . $my->pw);
} else {
$id = 0;
$lastvisit = $this->cookielastvisit;
$my->clv = $this->cookielastvisit;
$my->vlogin = false;
makecookie($config['cookie_prefix'] . '_vdata', "|", -60);
}
makecookie($config['cookie_prefix'] . '_vlastvisit', $lastvisit);
$my->is_bot = $this->log_robot();
$this->sid = $this->construct_sid();
$my->sid =& $this->sid;
$my->mark = serialize(array());
$my->pwfaccess = serialize(array());
$my->settings = serialize(array());
$action = $gpc->get('action', str);
$qid = $gpc->get('id', int);
$db->query("INSERT INTO {$db->pre}session\n\t(sid, mid, wiw_script, wiw_action, wiw_id, active, ip, user_agent, lastvisit, mark, pwfaccess, settings, is_bot) VALUES\n\t('{$this->sid}', '{$id}','" . SCRIPTNAME . "','{$action}','{$qid}','" . time() . "','{$this->ip}','" . $gpc->save_str(htmlspecialchars($this->user_agent)) . "','{$lastvisit}','{$my->mark}','{$my->pwfaccess}','{$my->settings}','{$my->is_bot}')", __LINE__, __FILE__);
return $my;
}
示例8: validation_form_action
function validation_form_action(array $form, array $posting, array $report)
{
return array_empty($report) ? $form['success']($posting) : $form['fail']($posting, $report);
}
示例9: array
$input = array();
foreach ($fields as $key => $data) {
$value = $gpc->get($key, $data[1], DONT_CARE);
if ($key == 'regdate' || $key == 'lastvisit') {
if (is_array($value) && array_sum($value) != 0) { // for php version >= 5.1.0
$input[$key] = @mktime(0, 0, 0, intval($value[2]), intval($value[1]), intval($value[3]));
if ($input[$key] == -1 || $input[$key] == false) { // -1 for php version < 5.1.0, false for php version >= 5.1.0
$input[$key] = DONT_CARE;
}
}
else {
$input[$key] = DONT_CARE;
}
}
elseif ($key == 'groups') {
if (array_empty($value) !== false) {
$input[$key] = DONT_CARE;
}
else {
$input[$key] = $value;
}
}
elseif ($key == 'birthday') {
if (!isset($value[1]) || !isset($value[2]) || !isset($value[3])) {
$input[$key] = DONT_CARE;
}
else {
$value[1] = intval(trim($value[1]));
if ($value[1] < 1 || $value[1] > 31) {
$value[1] = '%';
}
示例10: substr
if ($str[0] == '-') {
$not = 'NOT ';
$str = substr($str, 1);
} else {
$not = '';
}
if ($i > 0) {
$sql_where_like .= $op . $not;
}
if ($gpc->get('opt_0', int) == 0) {
$sql_where_like .= "(r.topic LIKE{$binary} '%{$str}%' OR r.comment LIKE{$binary} '%{$str}%') ";
} else {
$sql_where_like .= "r.topic LIKE{$binary} '%{$str}%' ";
}
}
if (array_empty($boards)) {
$boards = $slog->getBoards();
}
$sql_where = $slog->sqlinboards('r.board', 1, $boards) . " ";
if (count($used) > 0) {
$sql_where .= "({$sql_where_like}) ";
}
if (empty($rname) == false) {
if (count($used) > 0) {
$sql_where .= "AND ";
}
$sql_where .= "r.name = '{$rname}' ";
}
if (strxlen($name) >= $config['searchminlength']) {
$used[] = $name;
} else {
示例11: Parse
static function Parse($url)
{
// save 'original'
Url::$data['_url'] = $url;
// send through routes
Url::$data['url'] = Url::DoRoutes($url);
// get extension
preg_match('/(.*)\\.(\\w{1,4})$/Ui', Url::$data['url'], $matches);
if (!empty($matches)) {
Url::$data['url'] = $matches[1];
Url::$data['type'] = $matches[2];
}
// get parts
$parts = explode(DS, Url::$data['url']);
// is subdomain?
// if (count($host_parts=explode('.', $_SERVER['HTTP_HOST'])) > 2 && $host_parts[0]!='www') {
if (($subdomain = Url::GetSubdomain()) != null) {
Url::$data['is_subdomain'] = true;
Url::$data['subdomain'] = $subdomain;
}
Url::$data['host'] = 'http' . (array_get($_SERVER, 'HTTPS') ? 's' : '') . '://' . wrap($subdomain, '', '.') . DOMAIN;
// d($url);d_arr($parts);d_arr(Url::$data);die;
// nothing left?
if (array_empty($parts)) {
if (Url::GetData('is_admin')) {
// is admin
$parts = array(ADMIN_DEFAULT_CONTROLLER, ADMIN_DEFAULT_ACTION);
} else {
// is default
$parts = explode(DS, Url::GetData('is_subdomain') ? SUBDOMAIN_DEFAULT_URL : DEFAULT_URL);
}
}
// is execute?
if (Url::$data['type'] == 'php') {
Url::$data['model'] = 'app';
Url::$data['modelName'] = 'AppModel';
Url::$data['controller'] = EXECUTE_CONTROLLER;
Url::$data['controllerName'] = ucfirst(EXECUTE_CONTROLLER) . 'Controller';
Url::$data['action'] = 'include_to_buffer';
// set filename
Url::$data['params'] = array('filename' => implode(DS, $parts) . '.php');
} else {
// set controller
Url::$data['controller'] = array_shift($parts);
Url::$data['controllerName'] = AppInflector::classify(Url::$data['controller'], 'controller');
// set model
Url::$data['model'] = AppInflector::singularize(Url::$data['controller']);
Url::$data['modelName'] = AppInflector::classify(Url::$data['model'], 'model');
// set action
Url::$data['action'] = ($action = array_shift($parts)) != null ? $action : 'index';
// add prefix to admin actions
if (Url::GetData('is_admin')) {
Url::$data['action'] = ADMIN_PREFIX . Url::$data['action'];
}
// set params
while (($value = array_shift($parts)) != null) {
Url::$data['params'][] = $value;
}
}
// set request
Url::$data['request'] = $_REQUEST;
// set domain
Url::$data['domain'] = DOMAIN;
// d_arr(Url::$data);die;
}
示例12: home
public function home()
{
global $warning, $bio, $core, $warning;
$v = $this->__(w('path ext'));
if (array_empty($v)) {
$warning->now();
}
$location = XFS . XHTM . _tbrowser() . '/' . $v->ext . '/';
if (!@is_dir($location)) {
$warning->now();
}
$filename = _filename($v->path, $v->ext);
if ($v->ext == 'css' && $v->path != 'default') {
$v->field = !is_numb($v->path) ? 'alias' : 'id';
$sql = 'SELECT *
FROM _tree
WHERE tree_?? = ?
LIMIT 1';
if (!($tree = sql_fieldrow(sql_filter($sql, $v->field, $v->path)))) {
$warning->now();
}
$filetree = _rewrite($tree);
$filename = _filename('_tree_' . $filetree, $v->ext);
}
//
// 304 Not modified response header
if (@file_exists($location . $filename)) {
$f_last_modified = gmdate('D, d M Y H:i:s', filemtime($location . $filename)) . ' GMT';
$http_if_none_match = v_server('HTTP_IF_NONE_MATCH');
$http_if_modified_since = v_server('HTTP_IF_MODIFIED_SINCE');
header('Last-Modified: ' . $f_last_modified);
if ($f_last_modified == $http_if_modified_since) {
header('HTTP/1.0 304 Not Modified');
header('Content-Length: 0');
exit;
}
}
switch ($v->ext) {
case 'css':
if ($v->path != 'default') {
$filetree = _rewrite($tree);
$filename = _filename('_tree_' . $filetree, $v->ext);
if (!@file_exists($location . $filename)) {
$warning->now();
}
}
$browser = _browser();
if (!empty($browser['browser'])) {
$custom = array($browser['browser'] . '-' . $browser['version'], $browser['browser']);
foreach ($custom as $row) {
$handler = _filename('_tree_' . $row, 'css');
if (@file_exists($location . $handler)) {
_style('includes', array('CSS' => _style_handler('css/' . $handler)));
}
}
}
_style_vreplace(false);
break;
case 'js':
if (!@file_exists($location . $filename)) {
$warning->now();
}
_style_vreplace(false);
break;
}
v_style(array('DOMAIN' => 'media'));
sql_close();
//
// Headers
$ext = _style_handler($v->ext . '/' . $filename);
switch ($v->ext) {
case 'css':
$content_type = 'text/css; charset=utf-8';
//$ext = preg_replace('#(border-radius\-?.*?)\: ?(([0-9]+)px;)#is', ((_browser('firefox')) ? '-moz-\1: \2' : ''), $ext);
$ext = preg_replace('/(#([0-9A-Fa-f]{3})\\b)/i', '#\\2\\2', $ext);
$ext = preg_replace('#\\/\\*(.*?)\\*\\/#is', '', $ext);
$ext = str_replace(array("\r\n", "\n", "\t"), '', $ext);
break;
case 'js':
$content_type = 'application/x-javascript';
require_once XFS . XCOR . 'jsmin.php';
$ext = JSMin::minify($ext);
break;
}
ob_start('ob_gzhandler');
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 2592000) . ' GMT');
// 30 days = 60 * 60 * 24 * 30
header('Content-type: ' . $content_type);
echo $ext;
exit;
}
示例13: setProgress
public function setProgress()
{
// Cálculo del % de progreso
$progress = 100 * $this->score / $this->max;
$progress = round($progress, 0);
if ($progress > 100) {
$progress = 100;
}
if ($progress < 0) {
$progress = 0;
}
if ($this->status == 1 && $progress >= 80 && \array_empty($this->errors)) {
$this->finishable = true;
}
$this->progress = $progress;
// actualizar el registro
self::query("UPDATE project SET progress = :progress WHERE id = :id", array(':progress' => $this->progress, ':id' => $this->id));
}
示例14: wpsight_get_option
function wpsight_get_option($name, $default = false)
{
global $wpsight_wpml;
$options = get_option(WPSIGHT_DOMAIN);
// Get std value if default set TRUE and no options set
if ($default === true && (empty($options[$name]) || array_empty($options[$name]))) {
require_once WPSIGHT_ADMIN_DIR . '/options.php';
$options = wpsight_options();
if (!empty($options[$name]['std'])) {
return $options[$name]['std'];
}
}
if (array_empty($options)) {
return $default;
}
if (isset($options[$name])) {
if (in_array($name, $wpsight_wpml->wpsight_wpml_admin_texts())) {
return icl_t(WPSIGHT_NAME . ' - ' . __('Theme Options', 'wpsight-wpml'), $name, $options[$name]);
} else {
return $options[$name];
}
}
return $default;
}
示例15: wpsight_listing_title_action_favorite
function wpsight_listing_title_action_favorite($data)
{
$labels = array('favorites_add' => $data['label'], 'favorites_see' => __('Favorites', 'wpsight'));
$labels = apply_filters('wpsight_do_listing_title_actions_labels', $labels);
// Check if listings are still published
$favorites_removed = array();
if (isset($_COOKIE[WPSIGHT_COOKIE_FAVORITES])) {
$favorites = explode(',', $_COOKIE[WPSIGHT_COOKIE_FAVORITES]);
foreach ($favorites as $favorite) {
if (get_post_status($favorite) != 'publish') {
$favorites_removed[] = $favorite;
}
}
}
?>
<script type="text/javascript">
jQuery(document).ready(function($){
var cookie_favs = '<?php
echo WPSIGHT_COOKIE_FAVORITES;
?>
';
var removeValue = function(list, value) {
var values = list.split(",");
for(var i = 0 ; i < values.length ; i++) {
if(values[i] == value) {
values.splice(i, 1);
return values.join(",");
}
}
return list;
}; <?php
// Remove unpublished listings from cookie
if (!array_empty($favorites_removed)) {
foreach ($favorites_removed as $favorite_removed) {
echo 'var favs = removeValue($.cookie(cookie_favs), ' . $favorite_removed . ');';
}
echo '$.cookie(cookie_favs, favs,{ expires: 60, path: \'' . COOKIEPATH . '\' });';
}
?>
if($.cookie(cookie_favs)!=null) {
if($.cookie(cookie_favs).search('<?php
the_ID();
?>
')!=-1) {
$('.actions-favorites').hide();
$('.actions-favorites-link').show();
if($('.actions-favorites-link small').length == 0) {
$('.actions-favorites-link').append(' <span class="badge badge-important">' + $.cookie(cookie_favs).split(',').length + '</span>');
}
}
}
$('.actions-favorites').click(function(e) {
e.preventDefault();
if($.cookie(cookie_favs)==null || $.cookie(cookie_favs)=='') {
$.cookie(cookie_favs, <?php
the_ID();
?>
,{ expires: 60, path: '<?php
echo COOKIEPATH;
?>
' });
} else {
var fav = $.cookie(cookie_favs);
$.cookie(cookie_favs, fav + ',' + <?php
the_ID();
?>
,{ expires: 60, path: '<?php
echo COOKIEPATH;
?>
' });
}
$(this).fadeOut(75, function() {
$('.actions-favorites-link').fadeIn(75);
$('.actions-favorites-link').append(' <span class="badge badge-important">' + $.cookie(cookie_favs).split(',').length + '</span>');
});
});
});
</script><?php
$output = '';
if (is_pagetemplate_active('page-tpl-favorites.php')) {
// Save Button
$output .= '<a href="' . $data['href'] . '" id="' . $data['id'] . '" class="' . $data['class'] . '" target="' . $data['target'] . '" ' . $data['atts'] . '>';
// check if icon is available
if ($data['icon']) {
$output .= '<i class="' . $data['icon'] . '"></i>';
}
$output .= $labels['favorites_add'];
$output .= '</a>';
// Favorites Button
$output .= '<a href="' . get_pagetemplate_permalink('page-tpl-favorites.php') . '" class="' . apply_filters('wpsight_title_action_css', 'btn btn-mini actions-favorites-link action-link', 'favorites_see') . '" style="display:none">';
$output .= '<i class="icon-star"></i>' . $labels['favorites_see'];
$output .= '</a>';
}
// return output
return $output;
}