当前位置: 首页>>代码示例>>PHP>>正文


PHP XMLParser::ReturnArray方法代码示例

本文整理汇总了PHP中XMLParser::ReturnArray方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLParser::ReturnArray方法的具体用法?PHP XMLParser::ReturnArray怎么用?PHP XMLParser::ReturnArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XMLParser的用法示例。


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

示例1: array

 function _ResponseResultToResponseArray($SomeResult)
 {
     $this->responsearray = array();
     if (empty($SomeResult)) {
         // $SomeArray
         // we have an error
         $this->responsearray['status'] = 'Error';
         $this->responsearray['statusCode'] = '500';
         $this->responsearray['errorDescription'] = 'No Response';
         return;
     }
     //echo '<br>$this->ContentType='.$this->ContentType.'<br>';
     if ($this->ContentType != 'JSON' && $this->ContentType != 'PHPSERIAL' && $this->ContentType != 'XML') {
         $this->ContentType = 'JSON';
     }
     //echo '<br>$this->ContentType='.$this->ContentType.'<br>';
     if ($this->ContentType == 'JSON') {
         if (class_exists('Services_JSON')) {
             //$JSONObj = new Services_JSON();
             //return $JSONObj->encode($SomeArray);
             $JSONObj = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
             $this->responsearray = $JSONObj->decode($SomeResult);
         } else {
             // throw error
             trigger_error("ERROR: Services_JSON class not available", E_USER_ERROR);
         }
     } else {
         if ($this->ContentType == 'XML') {
             if (class_exists('XMLParser')) {
                 $parser = new XMLParser($SomeResult, false, false);
                 $parser->Parse();
                 $this->responsearray = $parser->ReturnArray();
                 $this->responsearray = $this->responsearray['root'];
                 // this forces the 'results' response to always have a child 0, xml can omit this
                 if (isset($this->responsearray['results']) && is_array($this->responsearray['results']) && !isset($this->responsearray['results']['0']) && count($this->responsearray['results'] > 0)) {
                     $temparray = $this->responsearray['results'];
                     unset($this->responsearray['results']);
                     $this->responsearray['results']['0'] = $temparray;
                     unset($temparray);
                 }
                 //$XMLObj = new ArrayXML( $SomeArray );
                 //return  '<'.'?'.'xml version="1.0" encoding="UTF-8" ?'.'>'."\n".'<root>'."\n".$XMLObj->ReturnXML().'</root>';
             } else {
                 // throw error
                 trigger_error("ERROR: XMLParser class not available", E_USER_ERROR);
             }
         } else {
             if ($this->ContentType == 'PHPSERIAL') {
                 //return serialize($SomeArray);
                 $this->responsearray = unserialize($SomeResult);
                 //if ( is_array( $this->xmlarray ) )
                 //{
                 //	$this->xmlarray['root'] = array_changekeycase_r( $this->xmlarray['root'], CASE_LOWER );
                 //}
             }
         }
     }
     if (!empty($this->responsearray['status'])) {
         $this->Status = $this->responsearray['status'];
     }
     if (!empty($this->responsearray['statusCode'])) {
         $this->StatusCode = $this->responsearray['statusCode'];
     }
     if (!empty($this->responsearray['errorDescription'])) {
         $this->ErrorDescription = $this->responsearray['errorDescription'];
     }
     // $this->responsearray['status'] = 'Success'
     // $this->responsearray['statusCode'] = '200'
     //}
     // default
     //$JSONObj = new Services_JSON();
     //return $JSONObj->encode($SomeArray);
 }
开发者ID:sktanmoy,项目名称:bc-api,代码行数:73,代码来源:bcapi.class.php


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