• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP in_array函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: throwError

 /**
  * Throw file upload error, return true if error has been thrown, false if error has been catched
  *
  * @param int $number
  * @param string $text
  * @access public
  */
 public function throwError($number, $text = false, $exit = true)
 {
     if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) {
         return false;
     }
     switch ($number) {
         case CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST:
         case CKFINDER_CONNECTOR_ERROR_INVALID_NAME:
         case CKFINDER_CONNECTOR_ERROR_THUMBNAILS_DISABLED:
         case CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED:
             header("HTTP/1.0 403 Forbidden");
             header("X-CKFinder-Error: " . $number);
             break;
         case CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED:
             header("HTTP/1.0 500 Internal Server Error");
             header("X-CKFinder-Error: " . $number);
             break;
         default:
             header("HTTP/1.0 404 Not Found");
             header("X-CKFinder-Error: " . $number);
             break;
     }
     if ($exit) {
         exit;
     }
 }
开发者ID:denglitong,项目名称:mvc,代码行数:33,代码来源:Http.php


示例2: setType

 public function setType($type = self::TYPE_UNDEFINED)
 {
     $type = (int) $type;
     if (in_array($type, array(self::TYPE_PAGE, self::TYPE_TEMPLATE, self::TYPE_UNDEFINED))) {
         $this->type = $type;
     }
 }
开发者ID:metterrothan,项目名称:cv-reboot-tpl-sys,代码行数:7,代码来源:Translation.class.php


示例3: PMA_sanitize

/**
 * Sanitizes $message, taking into account our special codes
 * for formatting.
 *
 * If you want to include result in element attribute, you should escape it.
 *
 * Examples:
 *
 * <p><?php echo PMA_sanitize($foo); ?></p>
 *
 * <a title="<?php echo PMA_sanitize($foo, true); ?>">bar</a>
 *
 * @uses    preg_replace()
 * @uses    strtr()
 * @param   string   the message
 * @param   boolean  whether to escape html in result
 *
 * @return  string   the sanitized message
 *
 * @access  public
 */
function PMA_sanitize($message, $escape = false, $safe = false)
{
    if (!$safe) {
        $message = strtr($message, array('<' => '&lt;', '>' => '&gt;'));
    }
    $replace_pairs = array('[i]' => '<em>', '[/i]' => '</em>', '[em]' => '<em>', '[/em]' => '</em>', '[b]' => '<strong>', '[/b]' => '</strong>', '[strong]' => '<strong>', '[/strong]' => '</strong>', '[tt]' => '<code>', '[/tt]' => '</code>', '[code]' => '<code>', '[/code]' => '</code>', '[kbd]' => '<kbd>', '[/kbd]' => '</kbd>', '[br]' => '<br />', '[/a]' => '</a>', '[sup]' => '<sup>', '[/sup]' => '</sup>');
    $message = strtr($message, $replace_pairs);
    $pattern = '/\\[a@([^"@]*)@([^]"]*)\\]/';
    if (preg_match_all($pattern, $message, $founds, PREG_SET_ORDER)) {
        $valid_links = array('http', './Do', './ur');
        foreach ($founds as $found) {
            // only http... and ./Do... allowed
            if (!in_array(substr($found[1], 0, 4), $valid_links)) {
                return $message;
            }
            // a-z and _ allowed in target
            if (!empty($found[2]) && preg_match('/[^a-z_]+/i', $found[2])) {
                return $message;
            }
        }
        if (substr($found[1], 0, 4) == 'http') {
            $message = preg_replace($pattern, '<a href="' . PMA_linkURL($found[1]) . '" target="\\2">', $message);
        } else {
            $message = preg_replace($pattern, '<a href="\\1" target="\\2">', $message);
        }
    }
    if ($escape) {
        $message = htmlspecialchars($message);
    }
    return $message;
}
开发者ID:dingdong2310,项目名称:g5_theme,代码行数:52,代码来源:sanitizing.lib.php


示例4: generateRoute

 /**
  * Add all the routes in the router in parameter
  * @param $router Router
  */
 public function generateRoute(Router $router)
 {
     foreach ($this->classes as $class) {
         $classMethods = get_class_methods($this->namespace . $class . 'Controller');
         $rc = new \ReflectionClass($this->namespace . $class . 'Controller');
         $parent = $rc->getParentClass();
         $parent = get_class_methods($parent->name);
         $className = $this->namespace . $class . 'Controller';
         foreach ($classMethods as $methodName) {
             if (in_array($methodName, $parent) || $methodName == 'index') {
                 continue;
             } else {
                 foreach (Router::getSupportedHttpMethods() as $httpMethod) {
                     if (strstr($methodName, $httpMethod)) {
                         continue 2;
                     }
                     if (in_array($methodName . $httpMethod, $classMethods)) {
                         $router->add('/' . strtolower($class) . '/' . $methodName, new $className(), $methodName . $httpMethod, $httpMethod);
                         unset($classMethods[$methodName . $httpMethod]);
                     }
                 }
                 $router->add('/' . strtolower($class) . '/' . $methodName, new $className(), $methodName);
             }
         }
         $router->add('/' . strtolower($class), new $className(), 'index');
     }
 }
开发者ID:kazuohirai,项目名称:awayfromswag,代码行数:31,代码来源:ClassRouting.php


示例5: all_for_post

 public static function all_for_post($post_id, $args = array())
 {
     $enclosures = array();
     $file_types_for_this_episode = array();
     $wordpress_enclosures = get_post_meta($post_id, 'enclosure', false);
     foreach ($wordpress_enclosures as $enclosure_data) {
         $enclosure = Enclosure::from_enclosure_meta($enclosure_data, $post_id);
         if ($enclosure->file_type && !in_array($enclosure->file_type->id, $file_types_for_this_episode)) {
             $file_types_for_this_episode[] = $enclosure->file_type->id;
         }
         $enclosures[] = $enclosure;
     }
     // process podPress files
     $podPress_enclosures = get_post_meta($post_id, '_podPressMedia', false);
     if (is_array($podPress_enclosures) && !empty($podPress_enclosures)) {
         foreach ($podPress_enclosures[0] as $file) {
             $enclosure = Enclosure::from_enclosure_podPress($file, $post_id);
             if (in_array($enclosure->file_type->id, $file_types_for_this_episode)) {
                 continue;
             }
             $file_types_for_this_episode[] = $enclosure->file_type->id;
             $enclosures[] = $enclosure;
         }
     }
     // if ( isset( $args['only_valid'] ) && $args['only_valid'] ) {
     // 	foreach ( $enclosures as $enclosure ) {
     // 		if ( $enclosure->errors ) {
     // 			// unset( current( $enclosure ) );
     // 		}
     // 	}
     // }
     return $enclosures;
 }
开发者ID:johannes-mueller,项目名称:podlove-publisher,代码行数:33,代码来源:enclosure.php


示例6: PrepareSettings

	function PrepareSettings($arUserField)
	{
		$arUserField["SETTINGS"] = (is_array($arUserField["SETTINGS"]) ? $arUserField["SETTINGS"] : @unserialise($arUserField["SETTINGS"]));
		$arUserField["SETTINGS"] = (is_array($arUserField["SETTINGS"]) ? $arUserField["SETTINGS"] : array());
		$tmp = array("CHANNEL_ID" => intval($arUserField["SETTINGS"]["CHANNEL_ID"]));

		if ($arUserField["SETTINGS"]["CHANNEL_ID"] == "add")
		{
			$tmp["CHANNEL_TITLE"] = trim($arUserField["SETTINGS"]["CHANNEL_TITLE"]);
			$tmp["CHANNEL_SYMBOLIC_NAME"] = trim($arUserField["SETTINGS"]["CHANNEL_SYMBOLIC_NAME"]);
			$tmp["CHANNEL_USE_CAPTCHA"] = ($arUserField["SETTINGS"]["CHANNEL_USE_CAPTCHA"] == "Y" ? "Y" : "N");
		}

		$uniqType = $arUserField["SETTINGS"]["UNIQUE"];
		if (is_array($arUserField["SETTINGS"]["UNIQUE"]))
		{
			$uniqType = 0;
			foreach ($arUserField["SETTINGS"]["UNIQUE"] as $z){
				$uniqType |= $z;
			}
			$uniqType += 5;
		}

		$tmp["UNIQUE"] = $uniqType;
		$tmp["UNIQUE_IP_DELAY"] = is_array($arUserField["SETTINGS"]["UNIQUE_IP_DELAY"]) ?
			$arUserField["SETTINGS"]["UNIQUE_IP_DELAY"] : array();
		$tmp["NOTIFY"] = (in_array($arUserField["SETTINGS"]["NOTIFY"], array("I", "Y", "N")) ?
			$arUserField["SETTINGS"]["NOTIFY"] : "N");

		return $tmp;
	}
开发者ID:ASDAFF,项目名称:bitrix-5,代码行数:31,代码来源:usertypevote.php


示例7: _validate

	protected function _validate($context)
	{
		$config = $this->_config;
		$row = $context->caller;

		if (is_uploaded_file($row->file) && $config->restrict && !in_array($row->extension, $config->ignored_extensions->toArray())) 
		{
			if ($row->isImage()) 
			{
				if (getimagesize($row->file) === false) {
					$context->setError(JText::_('WARNINVALIDIMG'));
					return false;
				}
			}
			else 
			{
				$mime = KFactory::get('com://admin/files.database.row.file')->setData(array('path' => $row->file))->mimetype;

				if ($config->check_mime && $mime) 
				{
					if (in_array($mime, $config->illegal_mimetypes->toArray()) || !in_array($mime, $config->allowed_mimetypes->toArray())) {
						$context->setError(JText::_('WARNINVALIDMIME'));
						return false;
					}
				}
				elseif (!$config->authorized) {
					$context->setError(JText::_('WARNNOTADMIN'));
					return false;
				}
			}
		}
	}
开发者ID:raeldc,项目名称:com_learn,代码行数:32,代码来源:mimetype.php


示例8: getLinkDefsInFieldMeta

 /**
  * Get link definition defined in 'fields' metadata. In linkDefs can be used as value (e.g. "type": "hasChildren") and/or variables (e.g. "entityName":"{entity}"). Variables should be defined into fieldDefs (in 'entityDefs' metadata).
  *
  * @param  string $entityName
  * @param  array  $fieldDef
  * @param  array  $linkFieldDefsByType
  * @return array | null
  */
 public function getLinkDefsInFieldMeta($entityName, $fieldDef, array $linkFieldDefsByType = null)
 {
     if (!isset($fieldDefsByType)) {
         $fieldDefsByType = $this->getFieldDefsByType($fieldDef);
         if (!isset($fieldDefsByType['linkDefs'])) {
             return null;
         }
         $linkFieldDefsByType = $fieldDefsByType['linkDefs'];
     }
     foreach ($linkFieldDefsByType as $paramName => &$paramValue) {
         if (preg_match('/{(.*?)}/', $paramValue, $matches)) {
             if (in_array($matches[1], array_keys($fieldDef))) {
                 $value = $fieldDef[$matches[1]];
             } else {
                 if (strtolower($matches[1]) == 'entity') {
                     $value = $entityName;
                 }
             }
             if (isset($value)) {
                 $paramValue = str_replace('{' . $matches[1] . '}', $value, $paramValue);
             }
         }
     }
     return $linkFieldDefsByType;
 }
开发者ID:chinazan,项目名称:zzcrm,代码行数:33,代码来源:Helper.php


示例9: beforeAction

 public function beforeAction($action)
 {
     if (!$this->owner instanceof MobileController && !in_array($this->owner->action->getId(), array_keys($this->actions()))) {
         return true;
     }
     Yii::app()->user->loginUrl = array('/mobile/login');
     Yii::app()->params->isMobileApp = true;
     // fix profile linkable behavior since model was instantiated before action
     if (!preg_match('/\\/mobileView$/', Yii::app()->params->profile->asa('X2LinkableBehavior')->viewRoute)) {
         Yii::app()->params->profile->asa('X2LinkableBehavior')->viewRoute .= '/mobileView';
     }
     $this->dataUrl = $this->owner->createAbsoluteUrl($action->getId());
     $this->pageId = lcfirst(preg_replace('/Controller$/', '', get_class($this->owner))) . '-' . $action->getId();
     $cookie = new CHttpCookie('isMobileApp', 'true');
     // create cookie
     $cookie->expire = 2147483647;
     // max expiration time
     Yii::app()->request->cookies['isMobileApp'] = $cookie;
     // save cookie
     if (!$this->owner instanceof MobileController) {
         $this->owner->layout = $this->pathAliasBase . 'views.layouts.main';
         if ($this->owner->module) {
             $this->owner->setAssetsUrl(Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias($this->pathAliasBase . 'assets'), false, -1, true));
             $this->owner->module->assetsUrl = $this->owner->assetsUrl;
             Yii::app()->clientScript->packages = MobileModule::getPackages($this->owner->module->assetsUrl);
         } else {
             Yii::app()->clientScript->packages = MobileModule::getPackages($this->owner->assetsUrl);
         }
     }
     return true;
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:31,代码来源:X2MobileControllerBehavior.php


示例10: fetch_all

 public function fetch_all($cachenames, $lv)
 {
     global $_G;
     $data = array();
     if ($lv > 1 && !$cachenames) {
         $cachenames = $_G[_config][cache_list];
     }
     if (defined('DEBUG')) {
         $name = $this->obj->name;
         if (in_array($name, array('memcache', 'baichuan'))) {
             $_G['memory_debug']['get'] = array();
             if (is_array($cachenames)) {
                 $_G['memory_debug']['get'] = $cachenames;
             } else {
                 $_G['memory_debug']['get'][] = $key;
             }
         }
     }
     $data = $this->obj->get($cachenames);
     if ($data === false || $data === NULL) {
         $this->update($cachenames);
     }
     if (is_array($cachenames)) {
         foreach ($data as $k => $v) {
             if ($v === false) {
                 $data[$k] = $this->update($k);
             }
         }
     }
     return $data;
 }
开发者ID:lqlstudio,项目名称:ttae_open,代码行数:31,代码来源:cache.class.php


示例11: getEntityAlias

 /**
  * {@inheritdoc}
  */
 public function getEntityAlias($entityClass)
 {
     if ($this->configManager->hasConfig($entityClass)) {
         // check for enums
         $enumCode = $this->configManager->getProvider('enum')->getConfig($entityClass)->get('code');
         if ($enumCode) {
             $entityAlias = $this->getEntityAliasFromConfig($entityClass);
             if (null !== $entityAlias) {
                 return $entityAlias;
             }
             return $this->createEntityAlias(str_replace('_', '', $enumCode));
         }
         // check for dictionaries
         $groups = $this->configManager->getProvider('grouping')->getConfig($entityClass)->get('groups');
         if (!empty($groups) && in_array(GroupingScope::GROUP_DICTIONARY, $groups, true)) {
             // delegate aliases generation to default provider
             return null;
         }
         // exclude hidden entities
         if ($this->configManager->isHiddenModel($entityClass)) {
             return false;
         }
         // check for custom entities
         if (ExtendHelper::isCustomEntity($entityClass)) {
             $entityAlias = $this->getEntityAliasFromConfig($entityClass);
             if (null !== $entityAlias) {
                 return $entityAlias;
             }
             return $this->createEntityAlias('Extend' . ExtendHelper::getShortClassName($entityClass));
         }
     }
     return null;
 }
开发者ID:antrampa,项目名称:platform,代码行数:36,代码来源:ExtendEntityAliasProvider.php


示例12: moduleValidateConfiguration

/**	
 * Performs payment module specific configuration validation
 * 
 * @param string &$errorMessage			- error message when return result is not true
 * 
 * @return bool 						- true if configuration is valid, false otherwise
 * 
 * 
 */
function moduleValidateConfiguration(&$errorMessage)
{
    global $providerConf;
    $commomResult = commonValidateConfiguration($errorMessage);
    if (!$commomResult) {
        return false;
    }
    if (strlen(trim($providerConf['Param_sid'])) == 0) {
        $errorMessage = '\'Account number\' field is empty';
        return false;
    }
    if (!in_array($providerConf['Param_pay_method'], array('CC', 'CK'))) {
        $errorMessage = '\'Pay method\' field has incorrect value';
        return false;
    }
    if (strlen(trim($providerConf['Param_secret_word'])) == 0) {
        $errorMessage = '\'Secret word\' field is empty';
        return false;
    }
    if (strlen(trim($providerConf['Param_secret_word'])) > 16 || strpos($providerConf['Param_secret_word'], ' ') !== false) {
        $errorMessage = '\'Secret word\' field has incorrect value';
        return false;
    }
    return true;
}
开发者ID:BackupTheBerlios,项目名称:dolphin-dwbn-svn,代码行数:34,代码来源:2checkoutv2.php


示例13: convertDateMomentToPhp

 public static function convertDateMomentToPhp($format)
 {
     $tokens = ["M" => "n", "Mo" => "nS", "MM" => "m", "MMM" => "M", "MMMM" => "F", "D" => "j", "Do" => "jS", "DD" => "d", "DDD" => "z", "DDDo" => "zS", "DDDD" => "zS", "d" => "w", "do" => "wS", "dd" => "D", "ddd" => "D", "dddd" => "l", "e" => "w", "E" => "N", "w" => "W", "wo" => "WS", "ww" => "W", "W" => "W", "Wo" => "WS", "WW" => "W", "YY" => "y", "YYYY" => "Y", "gg" => "o", "gggg" => "o", "GG" => "o", "GGGG" => "o", "A" => "A", "a" => "a", "H" => "G", "HH" => "H", "h" => "g", "hh" => "h", "m" => "i", "mm" => "i", "s" => "s", "ss" => "s", "S" => "", "SS" => "", "SSS" => "", "z or zz" => "T", "Z" => "P", "ZZ" => "O", "X" => "U", "LT" => "g:i A", "L" => "m/d/Y", "l" => "n/j/Y", "LL" => "F jS Y", "ll" => "M j Y", "LLL" => "F js Y g:i A", "lll" => "M j Y g:i A", "LLLL" => "l, F jS Y g:i A", "llll" => "D, M j Y g:i A"];
     // find all tokens from string, using regular expression
     $regExp = "/(\\[[^\\[]*\\])|(\\\\)?(LT|LL?L?L?|l{1,4}|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|SS?S?|X|zz?|ZZ?|.)/";
     $matches = array();
     preg_match_all($regExp, $format, $matches);
     //  if there is no match found then return the string as it is
     //  TODO: might return escaped string
     if (empty($matches) || is_array($matches) === false) {
         return $format;
     }
     //  to match with extracted tokens
     $momentTokens = array_keys($tokens);
     $phpMatches = array();
     //  ----------------------------------
     foreach ($matches[0] as $id => $match) {
         // if there is a matching php token in token list
         if (in_array($match, $momentTokens)) {
             // use the php token instead
             $string = $tokens[$match];
         } else {
             $string = $match;
         }
         $phpMatches[$id] = $string;
     }
     // join and return php specific tokens
     return implode("", $phpMatches);
 }
开发者ID:rocketyang,项目名称:hasscms-app,代码行数:29,代码来源:FormatConverter.php


示例14: addnew

 function addnew()
 {
     if ($_POST) {
         $image = $_FILES['logo'];
         $image_name = $image['name'];
         $image_tmp = $image['tmp_name'];
         $image_size = $image['size'];
         $error = $image['error'];
         $file_ext = explode('.', $image_name);
         $file_ext = strtolower(end($file_ext));
         $allowed_ext = array('jpg', 'jpeg', 'bmp', 'png', 'gif');
         $file_on_server = '';
         if (in_array($file_ext, $allowed_ext)) {
             if ($error === 0) {
                 if ($image_size < 3145728) {
                     $file_on_server = uniqid() . '.' . $file_ext;
                     $destination = './brand_img/' . $file_on_server;
                     move_uploaded_file($image_tmp, $destination);
                 }
             }
         }
         $values = array('name' => $this->input->post('name'), 'description' => $this->input->post('desc'), 'logo' => $file_on_server, 'is_active' => 1);
         if ($this->brand->create($values)) {
             $this->session->set_flashdata('message', 'New Brand added successfully');
         } else {
             $this->session->set_flashdata('errormessage', 'Oops! Something went wrong!!');
         }
         redirect(base_url() . 'brands/');
     }
     $this->load->helper('form');
     $this->load->view('includes/header', array('title' => 'Add Brand'));
     $this->load->view('brand/new_brand');
     $this->load->view('includes/footer');
 }
开发者ID:PHP-web-artisans,项目名称:ustora_backend,代码行数:34,代码来源:brands.php


示例15: indexOp

 /**
  * 登录
  */
 public function indexOp()
 {
     if (!$this->isQQLogin()) {
         if (empty($_POST['username']) || empty($_POST['password']) || !in_array($_POST['client'], $this->client_type_array)) {
             output_error('登录失败');
         }
     }
     $model_member = Model('member');
     $array = array();
     if ($this->isQQLogin()) {
         $array['member_qqopenid'] = $_SESSION['openid'];
     } else {
         $array['member_name'] = $_POST['username'];
         $array['member_passwd'] = md5($_POST['password']);
     }
     $member_info = $model_member->getMemberInfo($array);
     if (!empty($member_info)) {
         $token = $this->_get_token($member_info['member_id'], $member_info['member_name'], $_POST['client']);
         if ($token) {
             if ($this->isQQLogin()) {
                 setNc2Cookie('username', $member_info['member_name']);
                 setNc2Cookie('key', $token);
                 header("location:" . WAP_SITE_URL . '/tmpl/member/member.html?act=member');
             } else {
                 output_data(array('username' => $member_info['member_name'], 'key' => $token));
             }
         } else {
             output_error('登录失败');
         }
     } else {
         output_error('用户名密码错误');
     }
 }
开发者ID:dotku,项目名称:shopnc_cnnewyork,代码行数:36,代码来源:login.php


示例16: openseadragon

 /**
  * Return a OpenSeadragon image viewer for the provided files.
  * 
  * @param File|array $files A File record or an array of File records.
  * @param int $width The width of the image viewer in pixels.
  * @param int $height The height of the image viewer in pixels.
  * @return string|null
  */
 public function openseadragon($files)
 {
     if (!is_array($files)) {
         $files = array($files);
     }
     // Filter out invalid images.
     $images = array();
     $imageNames = array();
     foreach ($files as $file) {
         // A valid image must be a File record.
         if (!$file instanceof File) {
             continue;
         }
         // A valid image must have a supported extension.
         $extension = pathinfo($file->original_filename, PATHINFO_EXTENSION);
         if (!in_array(strtolower($extension), $this->_supportedExtensions)) {
             continue;
         }
         $images[] = $file;
         $imageNames[explode(".", $file->filename)[0]] = openseadragon_dimensions($file, 'original');
     }
     // Return if there are no valid images.
     if (!$images) {
         return;
     }
     return $this->view->partial('common/openseadragon.php', array('images' => $images, 'imageNames' => $imageNames));
 }
开发者ID:UVicLibrary,项目名称:omeka-OpenSeadragon2,代码行数:35,代码来源:Openseadragon.php


示例17: apply

 /**
  * {@inheritdoc}
  */
 public function apply(DataSourceInterface $dataSource, $name, $data, array $options)
 {
     $expressionBuilder = $dataSource->getExpressionBuilder();
     if (is_array($data) && !isset($data['type'])) {
         $data['type'] = isset($options['type']) ? $options['type'] : self::TYPE_CONTAINS;
     }
     if (!is_array($data)) {
         $data = ['type' => self::TYPE_CONTAINS, 'value' => $data];
     }
     $fields = array_key_exists('fields', $options) ? $options['fields'] : [$name];
     $type = $data['type'];
     $value = array_key_exists('value', $data) ? $data['value'] : null;
     if (!in_array($type, [self::TYPE_NOT_EMPTY, self::TYPE_EMPTY], true) && '' === trim($value)) {
         return;
     }
     if (1 === count($fields)) {
         $dataSource->restrict($this->getExpression($expressionBuilder, $type, current($fields), $value));
         return;
     }
     $expressions = [];
     foreach ($fields as $field) {
         $expressions[] = $this->getExpression($expressionBuilder, $type, $field, $value);
     }
     $dataSource->restrict($expressionBuilder->orX(...$expressions));
 }
开发者ID:sylius,项目名称:grid,代码行数:28,代码来源:StringFilter.php


示例18: sanitizeUpload

 /**
  * 
  * Sanitizes a file-upload information array.  If no file has been 
  * uploaded, the information will be returned as null.
  * 
  * @param array $value An array of file-upload information.
  * 
  * @return mixed The sanitized upload information array, or null.
  * 
  */
 public function sanitizeUpload($value)
 {
     // if the value is not required, and is blank, sanitize to null
     $null = !$this->_filter->getRequire() && $this->_filter->validateBlank($value);
     if ($null) {
         return null;
     }
     // has to be an array
     if (!is_array($value)) {
         return null;
     }
     // presorted list of expected keys
     $expect = array('error', 'name', 'size', 'tmp_name', 'type');
     // remove unexpected keys
     foreach ($value as $key => $val) {
         if (!in_array($key, $expect)) {
             unset($value[$key]);
         }
     }
     // sort the list of remaining actual keys
     $actual = array_keys($value);
     sort($actual);
     // make sure the expected and actual keys match up
     if ($expect != $actual) {
         return null;
     }
     // if all the non-error values are empty, still null
     $empty = empty($value['name']) && empty($value['size']) && empty($value['tmp_name']) && empty($value['type']);
     if ($empty) {
         return null;
     }
     // everything looks ok, return as-is
     return $value;
 }
开发者ID:kalkin,项目名称:solarphp,代码行数:44,代码来源:SanitizeUpload.php


示例19: getMethod

 public function getMethod($address, $total)
 {
     $this->load->language('payment/alipay_direct');
     $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int) $this->config->get('pp_standard_geo_zone_id') . "' AND country_id = '" . (int) $address['country_id'] . "' AND (zone_id = '" . (int) $address['zone_id'] . "' OR zone_id = '0')");
     if ($this->config->get('alipay_direct_total') > $total) {
         $status = false;
     } elseif (!$this->config->get('alipay_direct_geo_zone_id')) {
         $status = true;
     } elseif ($query->num_rows) {
         $status = true;
     } else {
         $status = false;
     }
     //判断是否移动设备访问
     $this->load->helper('mobile');
     if (is_mobile()) {
         $status = false;
     }
     $currencies = array('CNY');
     if (!in_array(strtoupper($this->currency->getCode()), $currencies)) {
         $status = false;
     }
     $method_data = array();
     if ($status) {
         $method_data = array('code' => 'alipay_direct', 'title' => $this->language->get('text_title'), 'terms' => '', 'sort_order' => $this->config->get('alipay_direct_sort_order'));
     }
     return $method_data;
 }
开发者ID:monkeychen,项目名称:website,代码行数:28,代码来源:alipay_direct.php


示例20: process

 /**
  * @param \PHP_CodeSniffer_File $phpCsFile
  * @param int $stackPointer
  *
  * @return void
  */
 public function process(\PHP_CodeSniffer_File $phpCsFile, $stackPointer)
 {
     $tokens = $phpCsFile->getTokens();
     $docBlockEndIndex = $this->findRelatedDocBlock($phpCsFile, $stackPointer);
     if (!$docBlockEndIndex) {
         return;
     }
     $docBlockStartIndex = $tokens[$docBlockEndIndex]['comment_opener'];
     for ($i = $docBlockStartIndex + 1; $i < $docBlockEndIndex; $i++) {
         if ($tokens[$i]['type'] !== 'T_DOC_COMMENT_TAG') {
             continue;
         }
         if (!in_array($tokens[$i]['content'], ['@return'])) {
             continue;
         }
         $classNameIndex = $i + 2;
         if ($tokens[$classNameIndex]['type'] !== 'T_DOC_COMMENT_STRING') {
             continue;
         }
         $content = $tokens[$classNameIndex]['content'];
         $appendix = '';
         $spaceIndex = strpos($content, ' ');
         if ($spaceIndex) {
             $appendix = substr($content, $spaceIndex);
             $content = substr($content, 0, $spaceIndex);
         }
         if (empty($content)) {
             continue;
         }
         $parts = explode('|', $content);
         $this->fixParts($phpCsFile, $classNameIndex, $parts, $appendix);
     }
 }
开发者ID:Anna-KarinaOertzen,项目名称:code-sniffer,代码行数:39,代码来源:DocBlockReturnSelfSniff.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP in_array_case函数代码示例发布时间:2022-05-15
下一篇:
PHP in_Array函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap