當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Braintree_Util::delimiterToUnderscore方法代碼示例

本文整理匯總了PHP中Braintree_Util::delimiterToUnderscore方法的典型用法代碼示例。如果您正苦於以下問題:PHP Braintree_Util::delimiterToUnderscore方法的具體用法?PHP Braintree_Util::delimiterToUnderscore怎麽用?PHP Braintree_Util::delimiterToUnderscore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Braintree_Util的用法示例。


在下文中一共展示了Braintree_Util::delimiterToUnderscore方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _iteratorToArray

 /**
  * processes SimpleXMLIterator objects recursively
  *
  * @access protected
  * @param object $iterator
  * @return array xml converted to array
  */
 private static function _iteratorToArray($iterator)
 {
     $xmlArray = array();
     $value = null;
     // rewind the iterator and check if the position is valid
     // if not, return the string it contains
     $iterator->rewind();
     if (!$iterator->valid()) {
         return self::_typecastXmlValue($iterator);
     }
     for ($iterator->rewind(); $iterator->valid(); $iterator->next()) {
         $tmpArray = null;
         $value = null;
         // get the attribute type string for use in conditions below
         $attributeType = $iterator->attributes()->type;
         // extract the parent element via xpath query
         $parentElement = $iterator->xpath($iterator->key() . '/..');
         if ($parentElement[0] instanceof SimpleXMLIterator) {
             $parentElement = $parentElement[0];
             $parentKey = Braintree_Util::delimiterToCamelCase($parentElement->getName());
         } else {
             $parentElement = null;
         }
         if ($parentKey == "customFields") {
             $key = Braintree_Util::delimiterToUnderscore($iterator->key());
         } else {
             $key = Braintree_Util::delimiterToCamelCase($iterator->key());
         }
         // process children recursively
         if ($iterator->hasChildren()) {
             // return the child elements
             $value = self::_iteratorToArray($iterator->current());
             // if the element is an array type,
             // use numeric keys to allow multiple values
             if ($attributeType != 'array') {
                 $tmpArray[$key] = $value;
             }
         } else {
             // cast values according to attributes
             $tmpArray[$key] = self::_typecastXmlValue($iterator->current());
         }
         // set the output string
         $output = isset($value) ? $value : $tmpArray[$key];
         // determine if there are multiple tags of this name at the same level
         if (isset($parentElement) && $parentElement->attributes()->type == 'collection' && $iterator->hasChildren()) {
             $xmlArray[$key][] = $output;
             continue;
         }
         // if the element was an array type, output to a numbered key
         // otherwise, use the element name
         if ($attributeType == 'array') {
             $xmlArray[] = $output;
         } else {
             $xmlArray[$key] = $output;
         }
     }
     return $xmlArray;
 }
開發者ID:danielcoats,項目名稱:schoolpress,代碼行數:65,代碼來源:Parser.php

示例2: testDelimeterToUnderscore

 function testDelimeterToUnderscore()
 {
     $this->assertEquals("a_b_c", Braintree_Util::delimiterToUnderscore("a-b-c"));
 }
開發者ID:kingsolmn,項目名稱:CakePHP-Braintree-Plugin,代碼行數:4,代碼來源:UtilTest.php


注:本文中的Braintree_Util::delimiterToUnderscore方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。