本文整理汇总了PHP中array_change_key_case函数的典型用法代码示例。如果您正苦于以下问题:PHP array_change_key_case函数的具体用法?PHP array_change_key_case怎么用?PHP array_change_key_case使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了array_change_key_case函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* 加载语言定义(不区分大小写)
* @param string $file 语言文件
* @param string $range 作用域
* @return mixed
*/
public static function load($file, $range = '')
{
$range = $range ? $range : self::$range;
$lang = is_file($file) ? include $file : [];
// 批量定义
return self::$lang[$range] = array_merge(self::$lang[$range], array_change_key_case($lang));
}
示例2: getPrivilegios
/**
*
* @param array $where
* @return stdClass
* @throws Exception
*/
public static function getPrivilegios(array $where = null)
{
$sucesso = new stdClass();
try {
$sql = 'SELECT ID
, ID_UNIDADE
, ID_RECURSO
, PERMISSAO
FROM TB_PRIVILEGIOS
WHERE ID_UNIDADE = :ID_UNIDADE';
if (isset($where['ID_RECURSO'])) {
$sql .= ' AND ID_RECURSO = :ID_RECURSO';
}
$stmt = Controlador::getInstance()->getConnection()->connection->prepare($sql);
if (isset($where['ID_RECURSO'])) {
$stmt->bindParam('ID_RECURSO', $where['ID_RECURSO'], PDO::PARAM_INT);
}
$stmt->bindParam('ID_UNIDADE', $where['ID_UNIDADE'], PDO::PARAM_INT);
$stmt->execute();
$out = $stmt->fetchAll(PDO::FETCH_ASSOC);
$out = array_change_key_case($out, CASE_LOWER);
$sucesso->success = true;
if (count($out) > 0) {
$sucesso->result = $out;
} else {
$sucesso->result = false;
}
} catch (PDOException $e) {
$sucesso->error = true;
$sucesso->result = 'Error Query: [' . $e->getMessage() . ']';
}
return $sucesso;
}
示例3: C
function C($name = null, $value = null, $default = null)
{
static $_config = array();
// 无参数时获取所有
if (empty($name)) {
return $_config;
}
// 优先执行设置获取或赋值
if (is_string($name)) {
if (!strpos($name, '.')) {
$name = strtoupper($name);
if (is_null($value)) {
return isset($_config[$name]) ? $_config[$name] : $default;
}
$_config[$name] = $value;
return null;
}
// 二维数组设置和获取支持
$name = explode('.', $name);
$name[0] = strtoupper($name[0]);
if (is_null($value)) {
return isset($_config[$name[0]][$name[1]]) ? $_config[$name[0]][$name[1]] : $default;
}
$_config[$name[0]][$name[1]] = $value;
return null;
}
// 批量设置
if (is_array($name)) {
$_config = array_merge($_config, array_change_key_case($name, CASE_UPPER));
return null;
}
return null;
// 避免非法参数
}
示例4: set
/**
* Cookie 设置、获取、删除
*
* @param string $name cookie名称
* @param mixed $value cookie值
* @param mixed $option 可选参数 可能会是 null|integer|string
*
* @return mixed
* @internal param mixed $options cookie参数
*/
public static function set($name, $value = '', $option = null)
{
!isset(self::$init) && self::init();
// 参数设置(会覆盖黙认设置)
if (!is_null($option)) {
if (is_numeric($option)) {
$option = ['expire' => $option];
} elseif (is_string($option)) {
parse_str($option, $option);
}
$config = array_merge(self::$config, array_change_key_case($option));
} else {
$config = self::$config;
}
$name = $config['prefix'] . $name;
// 设置cookie
if (is_array($value)) {
array_walk_recursive($value, 'self::jsonFormatProtect', 'encode');
$value = 'think:' . json_encode($value);
}
$expire = !empty($config['expire']) ? $_SERVER['REQUEST_TIME'] + intval($config['expire']) : 0;
if ($config['setcookie']) {
setcookie($name, $value, $expire, $config['path'], $config['domain'], $config['secure'], $config['httponly']);
}
$_COOKIE[$name] = $value;
}
示例5: init
/**
* Initialize log
*
* @return Zend_Log
* @throws Zend_Application_Resource_Exception
*/
public function init()
{
$log = $this->getLog();
$options = array_change_key_case($this->getOptions(), CASE_LOWER);
foreach ($options as $key => $value) {
switch ($key) {
case 'filters':
// @todo Filter support
require_once 'Zend/Application/Resource/Exception.php';
throw new Zend_Application_Resource_Exception('Unsupported
option.');
break;
case 'formatters':
// @todo Formatter support
require_once 'Zend/Application/Resource/Exception.php';
throw new Zend_Application_Resource_Exception('Unsupported
option.');
break;
case 'writers':
$this->getWriters($value);
break;
default:
break;
}
}
return $log;
}
示例6: getErrorMessageByCode
/**
* Get verbose error message by Error Code
* @param $errorCode
* @return string | false
*/
public function getErrorMessageByCode($errorCode)
{
$errorMessages = array('REJECTED_BY_ACQUIRER' => Mage::helper('bankdebit')->__('Your customers bank declined the transaction, your customer can contact their bank for more information'), 'Error_Generic' => Mage::helper('bankdebit')->__('An unhandled exception occurred'), '3DSecureDirectoryServerError' => Mage::helper('bankdebit')->__('A problem with Visa or MasterCards directory server, that communicates transactions for 3D-Secure verification'), 'AcquirerComunicationError' => Mage::helper('bankdebit')->__('Communication error with the acquiring bank'), 'AmountNotEqualOrderLinesTotal' => Mage::helper('bankdebit')->__('The sum of your order lines is not equal to the price set in initialize'), 'CardNotEligible' => Mage::helper('bankdebit')->__('Your customers card is not eligible for this kind of purchase, your customer can contact their bank for more information'), 'CreditCard_Error' => Mage::helper('bankdebit')->__('Some problem occurred with the credit card, your customer can contact their bank for more information'), 'PaymentRefusedByFinancialInstitution' => Mage::helper('bankdebit')->__('Your customers bank declined the transaction, your customer can contact their bank for more information'), 'Merchant_InvalidAccountNumber' => Mage::helper('bankdebit')->__('The merchant account number sent in on request is invalid'), 'Merchant_InvalidIpAddress' => Mage::helper('bankdebit')->__('The IP address the request comes from is not registered in PayEx, you can set it up in PayEx Admin under Merchant profile'), 'Access_MissingAccessProperties' => Mage::helper('bankdebit')->__('The merchant does not have access to requested functionality'), 'Access_DuplicateRequest' => Mage::helper('bankdebit')->__('Your customers bank declined the transaction, your customer can contact their bank for more information'), 'Admin_AccountTerminated' => Mage::helper('bankdebit')->__('The merchant account is not active'), 'Admin_AccountDisabled' => Mage::helper('bankdebit')->__('The merchant account is not active'), 'ValidationError_AccountLockedOut' => Mage::helper('bankdebit')->__('The merchant account is locked out'), 'ValidationError_Generic' => Mage::helper('bankdebit')->__('Generic validation error'), 'ValidationError_HashNotValid' => Mage::helper('bankdebit')->__('The hash on request is not valid, this might be due to the encryption key being incorrect'), 'ValidationError_InvalidParameter' => Mage::helper('bankdebit')->__('One of the input parameters has invalid data. See paramName and description for more information'), 'OperationCancelledbyCustomer' => Mage::helper('bankdebit')->__('The operation was cancelled by the client'), 'PaymentDeclinedDoToUnspecifiedErr' => Mage::helper('bankdebit')->__('Unexpecter error at 3rd party'), 'InvalidAmount' => Mage::helper('bankdebit')->__('The amount is not valid for this operation'), 'NoRecordFound' => Mage::helper('bankdebit')->__('No data found'), 'OperationNotAllowed' => Mage::helper('bankdebit')->__('The operation is not allowed, transaction is in invalid state'), 'ACQUIRER_HOST_OFFLINE' => Mage::helper('bankdebit')->__('Could not get in touch with the card issuer'), 'ARCOT_MERCHANT_PLUGIN_ERROR' => Mage::helper('bankdebit')->__('The card could not be verified'), 'REJECTED_BY_ACQUIRER_CARD_BLACKLISTED' => Mage::helper('bankdebit')->__('There is a problem with this card'), 'REJECTED_BY_ACQUIRER_CARD_EXPIRED' => Mage::helper('bankdebit')->__('The card expired'), 'REJECTED_BY_ACQUIRER_INSUFFICIENT_FUNDS' => Mage::helper('bankdebit')->__('Insufficient funds'), 'REJECTED_BY_ACQUIRER_INVALID_AMOUNT' => Mage::helper('bankdebit')->__('Incorrect amount'), 'USER_CANCELED' => Mage::helper('bankdebit')->__('Payment cancelled'), 'CardNotAcceptedForThisPurchase' => Mage::helper('bankdebit')->__('Your Credit Card not accepted for this purchase'));
$errorMessages = array_change_key_case($errorMessages, CASE_UPPER);
$errorCode = mb_strtoupper($errorCode);
return isset($errorMessages[$errorCode]) ? $errorMessages[$errorCode] : false;
}
示例7: createDeployer
/** @return Deployer */
private function createDeployer($config)
{
$config = array_change_key_case($config, CASE_LOWER) + ['local' => '', 'passivemode' => TRUE, 'ignore' => '', 'allowdelete' => TRUE, 'purge' => '', 'before' => '', 'after' => '', 'preprocess' => TRUE];
if (empty($config['remote']) || !parse_url($config['remote'])) {
throw new \Exception("Missing or invalid 'remote' URL in config.");
}
$server = parse_url($config['remote'], PHP_URL_SCHEME) === 'sftp' ? new SshServer($config['remote']) : new FtpServer($config['remote'], (bool) $config['passivemode']);
if (!preg_match('#/|\\\\|[a-z]:#iA', $config['local'])) {
if ($config['local'] && getcwd() !== dirname($this->configFile)) {
$this->logger->log('WARNING: the "local" path is now relative to the directory where ' . basename($this->configFile) . ' is placed', 'red');
}
$config['local'] = dirname($this->configFile) . '/' . $config['local'];
}
$deployment = new Deployer($server, $config['local'], $this->logger);
if ($config['preprocess']) {
$deployment->preprocessMasks = $config['preprocess'] == 1 ? ['*.js', '*.css'] : self::toArray($config['preprocess']);
// intentionally ==
$preprocessor = new Preprocessor($this->logger);
$deployment->addFilter('js', [$preprocessor, 'expandApacheImports']);
$deployment->addFilter('js', [$preprocessor, 'compressJs'], TRUE);
$deployment->addFilter('css', [$preprocessor, 'expandApacheImports']);
$deployment->addFilter('css', [$preprocessor, 'expandCssImports']);
$deployment->addFilter('css', [$preprocessor, 'compressCss'], TRUE);
}
$deployment->ignoreMasks = array_merge(['*.bak', '.svn', '.git*', 'Thumbs.db', '.DS_Store'], self::toArray($config['ignore']));
$deployment->deploymentFile = empty($config['deploymentfile']) ? $deployment->deploymentFile : $config['deploymentfile'];
$deployment->allowDelete = $config['allowdelete'];
$deployment->toPurge = self::toArray($config['purge'], TRUE);
$deployment->runBefore = self::toArray($config['before'], TRUE);
$deployment->runAfter = self::toArray($config['after'], TRUE);
$deployment->testMode = !empty($config['test']) || $this->mode === 'test';
return $deployment;
}
示例8: readExifTags
/**
* Read the Information from a picture according to the fields specified in CCK
* @param $file
* @param $arTagNames
* @return array
*/
public function readExifTags($file, $arTagNames = array())
{
if (!file_exists($file)) {
return array();
}
$ar_supported_types = array('jpg', 'jpeg');
if (!in_array(strtolower($this->getFileType($file)), $ar_supported_types)) {
return array();
}
$exif = exif_read_data($file, 0);
$arSmallExif = array();
$arSmallExif = array_change_key_case((array) $exif, CASE_LOWER);
$arSmallExif['computed'] = array_change_key_case((array) $arSmallExif['computed'], CASE_LOWER);
//why this function isn't recursive is beyond me
$arSmallExif['thumbnail'] = array_change_key_case((array) $arSmallExif['thumbnail'], CASE_LOWER);
$arSmallExif['comment'] = array_change_key_case((array) $arSmallExif['comment'], CASE_LOWER);
$info = array();
foreach ($arTagNames as $tagName) {
if ($tagName['section'] != 'iptc') {
if (!empty($arSmallExif[$tagName['tag']])) {
$info[$tagName['section'] . '_' . $tagName['tag']] = $arSmallExif[$tagName['tag']];
} elseif (!empty($arSmallExif[$tagName['section']][$tagName['tag']])) {
$info[$tagName['section'] . '_' . $tagName['tag']] = $arSmallExif[$tagName['section']][$tagName['tag']];
}
}
}
foreach ($info as $tag => $value) {
if (!is_array($value)) {
$info[$tag] = utf8_encode($value);
}
}
return $info;
}
示例9: initialize
/**
* Initialization hook method.
*
* @return void
*/
public function initialize(array $params)
{
self::$instance =& $this;
$session = $this->request->session();
// load botdetect captcha library
LibraryLoader::load($session);
// change the keys in $param array to lowercase,
// this will avoid user being able to pass in a lowercase option (e.g. captchaconfig)
$params = array_change_key_case($params, CASE_LOWER);
if (empty($params) || !array_key_exists('captchaconfig', $params) || empty($params['captchaconfig'])) {
$errorMessage = 'The BotDetect Captcha component requires you to declare "captchaConfig" option and assigns a captcha configuration key defined in config/captcha.php file.<br>';
$errorMessage .= 'For example: $this->loadComponent(\'CakeCaptcha.Captcha\', [\'captchaConfig\' => \'ContactCaptcha\']);';
throw new InvalidArgumentException($errorMessage);
}
$captchaId = $params['captchaconfig'];
// get captcha config
$config = UserCaptchaConfiguration::get($captchaId);
if (null === $config) {
throw new InvalidArgumentException(sprintf('The "%s" option could not be found in config/captcha.php file.', $captchaId));
}
if (!is_array($config)) {
throw new UnexpectedTypeException($config, 'array');
}
// save user's captcha configuration options
UserCaptchaConfiguration::save($config);
// init botdetect captcha instance
$this->initCaptcha($config);
}
示例10: cleanFilter
/**
* Clean wrong fields and operations from filter.
* @param array $filter Filter.
* @return array Filter after clean.
*/
public function cleanFilter(array $filter)
{
$possibleFields = $this->entity->getFieldsForFilter();
$mapFields = $this->entity->getFieldsForMap();
$whiteFilter = array();
$filter = array_change_key_case($filter, CASE_UPPER);
foreach ($filter as $key => $value) {
if (is_numeric($key) && is_array($value)) {
continue;
}
if (preg_match('/^([^a-zA-Z]*)(.*)/', $key, $matches)) {
$operation = $matches[1];
$field = $matches[2];
if (!in_array($operation, $this->allowedOperations, true)) {
continue;
}
if (isset($possibleFields[$field])) {
if (isset($mapFields[$field])) {
$value = call_user_func_array($mapFields[$field]['IN'], array($value));
}
$whiteFilter[$key] = $value;
}
}
}
return $whiteFilter;
}
示例11: postRequest
/**
* Post request into gateway
*
* @param DataObject $request
* @param ConfigInterface $config
*
* @return DataObject
* @throws \Zend_Http_Client_Exception
*/
public function postRequest(DataObject $request, ConfigInterface $config)
{
$result = new DataObject();
$clientConfig = ['maxredirects' => 5, 'timeout' => 30, 'verifypeer' => $config->getValue('verify_peer')];
if ($config->getValue('use_proxy')) {
$clientConfig['proxy'] = $config->getValue('proxy_host') . ':' . $config->getValue('proxy_port');
$clientConfig['httpproxytunnel'] = true;
$clientConfig['proxytype'] = CURLPROXY_HTTP;
}
/** @var ZendClient $client */
$client = $this->httpClientFactory->create();
$client->setUri((bool) $config->getValue('sandbox_flag') ? $config->getValue('transaction_url_test_mode') : $config->getValue('transaction_url'));
$client->setConfig($clientConfig);
$client->setMethod(\Zend_Http_Client::POST);
$client->setParameterPost($request->getData());
$client->setHeaders(['X-VPS-VIT-CLIENT-CERTIFICATION-ID' => '33baf5893fc2123d8b191d2d011b7fdc', 'X-VPS-Request-ID' => $this->mathRandom->getUniqueHash(), 'X-VPS-CLIENT-TIMEOUT' => 45]);
$client->setUrlEncodeBody(false);
try {
$response = $client->request();
$responseArray = [];
parse_str(strstr($response->getBody(), 'RESULT'), $responseArray);
$result->setData(array_change_key_case($responseArray, CASE_LOWER));
$result->setData('result_code', $result->getData('result'));
} catch (\Zend_Http_Client_Exception $e) {
$result->addData(['response_code' => -1, 'response_reason_code' => $e->getCode(), 'response_reason_text' => $e->getMessage()]);
throw $e;
} finally {
$this->logger->debug(['request' => $request->getData(), 'result' => $result->getData()], (array) $config->getValue('getDebugReplacePrivateDataKeys'), (bool) $config->getValue('debug'));
}
return $result;
}
示例12: init
/**
* Init new cache file
*
* @param string $filename name of cache file
* @param array $skip_classes list of skipped from cache classes
* @return void
*/
public static function init($filename = NULL, array $skip_classes = NULL)
{
if (self::$_init) {
self::save();
}
if ($filename === NULL) {
$filename = self::$default_filename;
}
if (!self::$cache_dir) {
self::$cache_dir = Kohana::$cache_dir ? Kohana::$cache_dir : APPPATH . 'cache';
}
$filename = self::$cache_dir . DIRECTORY_SEPARATOR . $filename . EXT;
$is_file = is_file($filename);
if ($is_file) {
// timer('requere start');
require $filename;
// timer('requere stop');
}
if ($skip_classes !== NULL) {
self::$skip_classes += array_change_key_case(array_combine($skip_classes, $skip_classes), CASE_LOWER);
} else {
self::$skip_classes = array();
}
self::$_cache[] = array('filename' => $filename, 'is_file' => $is_file, 'mtime' => $is_file ? @filemtime($filename) : FALSE, 'size' => $is_file ? @filesize($filename) : FALSE, 'files' => array());
self::$_files =& self::$_cache[count(self::$_cache) - 1]['files'];
if (self::$_init === NULL) {
spl_autoload_unregister(array('Kohana', 'auto_load'));
spl_autoload_register(array('Ku_Loader', 'auto_load'));
register_shutdown_function(array('Ku_Loader', 'shutdown_handler'));
self::$_init = TRUE;
}
// die ('Init');
}
示例13: get
/**
* Get Consolidated
*
* @access public
* @param string $tas_uid, Task Uid
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function get ($tas_uid)
{
$criteria = new Criteria();
$criteria->addSelectColumn(CaseConsolidatedCorePeer::DYN_UID);
$criteria->addSelectColumn(\ReportTablePeer::REP_TAB_NAME);
$criteria->addSelectColumn(\ReportTablePeer::REP_TAB_UID);
$criteria->addSelectColumn(ContentPeer::CON_VALUE);
$criteria->addSelectColumn(CaseConsolidatedCorePeer::CON_STATUS);
$criteria->addJoin( CaseConsolidatedCorePeer::REP_TAB_UID, ReportTablePeer::REP_TAB_UID, Criteria::LEFT_JOIN );
$criteria->addJoin( CaseConsolidatedCorePeer::REP_TAB_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN );
$criteria->add( ContentPeer::CON_CATEGORY, "REP_TAB_TITLE");
$criteria->add( ContentPeer::CON_LANG, SYS_LANG);
$criteria->add( CaseConsolidatedCorePeer::TAS_UID, $tas_uid, Criteria::EQUAL );
$criteria->add( CaseConsolidatedCorePeer::CON_STATUS, 'ACTIVE', Criteria::EQUAL );
$dataset = CaseConsolidatedCorePeer::doSelectRS($criteria);
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
if ($dataset->next()) {
$response = $dataset->getRow();
} else {
$response = array(
'REP_TAB_UID' => '',
'REP_TAB_NAME' => '__' . $tas_uid,
'CON_VALUE' => '__' . $tas_uid,
);
}
return array_change_key_case($response, CASE_LOWER);;
}
示例14: run
/**
* {@inheritdoc}
*/
public function run(OptionsResolverInterface $resolver)
{
$records = array();
$localRecords = $this->localSource->execute();
$results = $this->ridicSource->execute();
foreach ($results as $key => $result) {
$result = array_change_key_case($result, CASE_LOWER);
$mrn = $result['hup_mrn'];
try {
$result['previous_record'] = $this->provider->getPatientByMRN($mrn);
} catch (PatientNotFoundException $e) {
unset($result, $results[$key]);
continue;
}
$result['identifier'] = $result['course_ser'];
$result['patient'] = $result['hup_mrn'];
$result['activity_date'] = $result['first_treatment_dt'];
$result['import_description'] = sprintf('%s ridic dose on the %s.', $result['course_ser'], $result['hup_mrn']);
$record = $resolver->resolve($result);
if ($record['patient'] && !in_array($record['course_ser'], $localRecords)) {
$records[] = $record;
}
unset($results[$key]);
}
return $records;
}
示例15: parseXmlAttr
public function parseXmlAttr($attr, $tag)
{
$attr = str_replace('&', '___', $attr);
$xml = '<tpl><tag ' . $attr . ' /></tpl>';
$xml = simplexml_load_string($xml);
if (!$xml) {
throw_exception(L('_XML_TAG_ERROR_') . ' : ' . $attr);
}
$xml = (array) $xml->tag->attributes();
$array = array_change_key_case($xml['@attributes']);
if ($array) {
$attrs = explode(',', $this->tags[strtolower($tag)]['attr']);
if (isset($this->tags[strtolower($tag)]['must'])) {
$must = explode(',', $this->tags[strtolower($tag)]['must']);
} else {
$must = array();
}
foreach ($attrs as $name) {
if (isset($array[$name])) {
$array[$name] = str_replace('___', '&', $array[$name]);
} elseif (false !== array_search($name, $must)) {
throw_exception(L('_PARAM_ERROR_') . ':' . $name);
}
}
return $array;
}
}