本文整理汇总了PHP中Braintree_Util::camelCaseToDelimiter方法的典型用法代码示例。如果您正苦于以下问题:PHP Braintree_Util::camelCaseToDelimiter方法的具体用法?PHP Braintree_Util::camelCaseToDelimiter怎么用?PHP Braintree_Util::camelCaseToDelimiter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Braintree_Util
的用法示例。
在下文中一共展示了Braintree_Util::camelCaseToDelimiter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _createElementsFromArray
/**
* Construct XML elements with attributes from an associative array.
*
* @access protected
* @static
* @param object $writer XMLWriter object
* @param array $aData contains attributes and values
* @return none
*/
private static function _createElementsFromArray(&$writer, $aData)
{
if (!is_array($aData)) {
$writer->text($aData);
return;
}
foreach ($aData as $index => $element) {
// convert the style back to gateway format
$elementName = Braintree_Util::camelCaseToDelimiter($index, '-');
// handle child elements
$writer->startElement($elementName);
if (is_array($element)) {
if (array_key_exists(0, $element) || empty($element)) {
$writer->writeAttribute('type', 'array');
foreach ($element as $ignored => $itemInArray) {
$writer->startElement('item');
self::_createElementsFromArray($writer, $itemInArray);
$writer->endElement();
}
} else {
self::_createElementsFromArray($writer, $element);
}
} else {
// generate attributes as needed
$attribute = self::_generateXmlAttribute($element);
if (is_array($attribute)) {
$writer->writeAttribute($attribute[0], $attribute[1]);
$element = $attribute[2];
}
$writer->text($element);
}
$writer->endElement();
}
}
示例2: _underscoreKeys
private function _underscoreKeys($array)
{
foreach ($array as $key => $value) {
$newKey = Braintree_Util::camelCaseToDelimiter($key, '_');
unset($array[$key]);
if (is_array($value)) {
$array[$newKey] = $this->_underscoreKeys($value);
} else {
$array[$newKey] = $value;
}
}
return $array;
}