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


PHP XML2Array::createArray方法代码示例

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


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

示例1: getParamsFromRequest

 /**
  * Parse params from request.
  * @return array
  */
 public function getParamsFromRequest()
 {
     $requestMethod = strtolower($_SERVER['REQUEST_METHOD']);
     switch ($requestMethod) {
         case 'get':
             $params = $_GET;
             break;
         case 'post':
             $params = $_POST;
             $xml = @simplexml_load_string($params['data']);
             if (false !== $xml && null !== $xml) {
                 $params = XML2Array::createArray($params['data']);
             }
             break;
         case 'put':
             parse_str(file_get_contents('php://input'), $params);
             $xml = @simplexml_load_string($params['data']);
             if (false !== $xml && null !== $xml) {
                 $params = XML2Array::createArray($params['data']);
             }
             $params['id'] = $_GET['id'];
             break;
         case 'delete':
             $params['id'] = $_GET['id'];
             break;
     }
     return $params;
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:32,代码来源:ApiRestRequest.php

示例2: __construct

 /**
  * @param string $xml - XML de resposta do Webservice
  */
 function __construct($xml)
 {
     $array = XML2Array::createArray($xml);
     foreach ($array as $indice => $valor) {
         $this->array = $valor;
         switch ($indice) {
             case 'AUTHORIZATION':
                 //GetAuthorized
                 $this->retornoAutorizacao();
                 break;
             case 'CONFIRMATION':
                 //vários casos
                 $this->retornoConfirmacao();
                 break;
             case 'COUNCIL':
                 //CouncilReport
                 $this->retornoVendas();
                 break;
             case 'REPORT':
                 //SalesSumm
                 $this->retornoRelatorio();
                 break;
             case 'ROOT':
                 //Erro no CouncilReport ou SalesSumm
                 $this->retornoErro();
                 break;
             default:
                 throw new \UnexpectedValueException('Retorno inesperado.');
         }
     }
     unset($this->array);
     //o atributo não será mais utilizado
 }
开发者ID:jonathanweb,项目名称:KomerciAPI,代码行数:36,代码来源:Response.php

示例3: _xml2array

 private static function _xml2array($xml)
 {
     if (!$xml || $xml == "") {
         return array();
     }
     require_once dirname(__FILE__) . "/xml2array.lib.class.php";
     return XML2Array::createArray($xml);
 }
开发者ID:huqq1987,项目名称:clone-lemon,代码行数:8,代码来源:mqs.sdk.class.php

示例4: transform

 /**
  * Transforms the API response into a PHP array
  *
  * @static
  * @param $response
  * @param $format
  * @return array|mixed|DOMDocument
  */
 public static function transform($response, $format)
 {
     if ($format == "json") {
         return json_decode($response);
     } elseif ($format == "xml") {
         return XML2Array::createArray($response);
     } else {
         throw new \Exception("{$format} transformer is not implemented yet");
     }
 }
开发者ID:nass600,项目名称:CosmBundle,代码行数:18,代码来源:ResponseToArrayTransformer.php

示例5: login

 protected function login($username = 'super', $password = 'super', $type = 'json')
 {
     $headers = array('Accept: application/' . $type, 'ZURMO_AUTH_USERNAME: ' . $username, 'ZURMO_AUTH_PASSWORD: ' . $password, 'ZURMO_API_REQUEST_TYPE: REST');
     $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/zurmo/api/login', 'POST', $headers);
     if ($type == 'json') {
         $response = json_decode($response, true);
     } elseif ($type == 'xml') {
         $response = XML2Array::createArray($response);
     }
     if ($response['status'] == ApiResponse::STATUS_SUCCESS) {
         return $response['data'];
     } else {
         return false;
     }
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:15,代码来源:ApiRestTest.php

示例6: getBookJSONFromXMLNode2

 /**
  * Obtiene y limpia el JSON final para insertar el ebook como documento
  * Limpia y agrega los campos de _id y lastUpdate
  */
 public static function getBookJSONFromXMLNode2($node)
 {
     //Funcion de procesamiento del XMl a la cadena JSON
     $arr = XML2Array::createArray($node);
     //Agrega last update y limpia el inicio y fin para simplificar la jerarquia
     //De esta forma no funciona al pasar a json se pierde
     //$arr['book']['lastUpdate'] = new MongoDate();
     $date = new MongoDate();
     $arr['book']['lastUpdate'] = array('$date' => $date->sec * 1000 + $date->usec / 1000);
     $mongo_id = str_replace('-', '', $arr['book']['@attributes']['id']);
     $arr['book']['_id'] = $mongo_id;
     //concvert to json
     $jsonContents = json_encode($arr);
     //Eliminación de datos innecesarios en la cadena JSON
     $json_string = Utils::cleanJSON($jsonContents);
     return $json_string;
 }
开发者ID:carlosmirandadiaz,项目名称:LectoGeeks,代码行数:21,代码来源:Utils.php

示例7: getResponse

 /**
  * getResponse function
  * This will get a detailed description from MedlinePlus Connect
  * @param $coding
  * @param $code
  * @return \Array
  */
 function getResponse($coding, $code)
 {
     if ($coding == 'ICD9') {
         $this->codingSystem = 'mainSearchCriteria.v.cs=2.16.840.1.113883.6.103';
     }
     if ($coding == 'SNOMED') {
         $this->codingSystem = 'mainSearchCriteria.v.cs=2.16.840.1.113883.6.96';
     }
     if ($coding == 'RXCUI') {
         $this->codingSystem = 'mainSearchCriteria.v.cs=2.16.840.1.113883.6.88';
     }
     if ($coding == 'NDC') {
         $this->codingSystem = 'mainSearchCriteria.v.cs=2.16.840.1.113883.6.69';
     }
     if ($coding == 'LOINC') {
         $this->codingSystem = 'mainSearchCriteria.v.cs=2.16.840.1.113883.6.1';
     }
     $urlBuilder = $this->medlineUrl . $this->codingSystem . '&mainSearchCriteria.v.c=' . $code;
     $xmlData = simplexml_load_file($urlBuilder);
     return \XML2Array::createArray($xmlData);
 }
开发者ID:igez,项目名称:gaiaehr,代码行数:28,代码来源:MedlinePlus.php

示例8: markers_deployable

function markers_deployable($res, $world)
{
    $markers = array();
    $xml = file_get_contents('vehicles.xml', true);
    require_once 'modules/lib/class.xml2array.php';
    $vehicles_xml = XML2Array::createArray($xml);
    while ($row = mysql_fetch_array($res)) {
        $Worldspace = str_replace("[", "", $row['Worldspace']);
        $Worldspace = str_replace("]", "", $Worldspace);
        $Worldspace = explode(",", $Worldspace);
        $x = 0;
        if (array_key_exists(1, $Worldspace)) {
            $x = $Worldspace[1];
        }
        $y = 0;
        if (array_key_exists(2, $Worldspace)) {
            $y = $Worldspace[2];
        }
        $type = $row['Classname'];
        $ltype = strtolower($type);
        if (array_key_exists('s' . $ltype, $vehicles_xml['vehicles'])) {
            $class = $vehicles_xml['vehicles']['s' . $ltype]['Type'];
        } else {
            $class = "Car";
        }
        require_once 'modules/calc.php';
        $description = '<h2><a href="index.php?view=info&show=5&id=' . $row['ObjectID'] . '">' . $type . '</a></h2><table><tr><td><img src="images/vehicles/' . $ltype . '.png" alt="" style="width: 100px;" /></td><td>&nbsp;&nbsp;&nbsp;</td><td style="vertical-align: top;"><h2>Position:</h2>Left: ' . round(world_x($x, $world)) . '<br />Top: ' . round(world_y($y, $world)) . '</td></tr></table>';
        $tmp = array();
        $tmp["lat"] = world_y($y, $world) / 10;
        $tmp["lng"] = world_x($x, $world) / 10;
        $tmp["icon"] = $class;
        $tmp["title"] = $type . " (" . $row['ObjectID'] . ")";
        $tmp["description"] = $description;
        $markers[] = $tmp;
    }
    return $markers;
}
开发者ID:Reema49,项目名称:dayz,代码行数:37,代码来源:markers.php

示例9: print_r

for ($i = 1; $i <= $pages; $i++) {
    print_r("page " . $i . "\n");
    $cases = XML2Array::createArray($ebay->getCases(200, $i));
    $cases = isset($cases["soapenv:Envelope"]["soapenv:Body"]["getUserCasesResponse"]["cases"]["caseSummary"]) ? $cases["soapenv:Envelope"]["soapenv:Body"]["getUserCasesResponse"]["cases"]["caseSummary"] : array();
    if (!empty($cases)) {
        print_r("cases: " . count($cases) . "\n");
        foreach ($cases as $j => $caseShort) {
            if (isset($caseShort['user']) && $caseShort['user']['userId'] == "chandlermotorsportsinc" && $caseShort['user']['role'] == "SELLER") {
                $sql = "SELECT * FROM cases where caseId = '" . $caseShort['caseId']['id'] . "'";
                $rs = $db->Execute($sql);
                $row = $rs->FetchRow();
                if (isset($row['caseId'])) {
                    print_r("case: " . $row['caseId'] . " exists" . "\n");
                    continue;
                }
                $case = XML2Array::createArray($ebay->getCaseDetails($caseShort['caseId']['id'], $caseShort['caseId']['type']));
                $case = isset($case["soapenv:Envelope"]["soapenv:Body"]["getEBPCaseDetailResponse"]) ? $case["soapenv:Envelope"]["soapenv:Body"]["getEBPCaseDetailResponse"] : array();
                if (!isset($case['caseSummary']['caseId']['id'])) {
                    $caseSummary = $caseShort;
                    $caseDetail = array();
                } else {
                    $caseSummary = $case['caseSummary'];
                    $caseDetail = isset($case['caseDetail']) ? $case['caseDetail'] : array();
                }
                $status = isset($caseSummary['status']) ? array_values($caseSummary['status']) : array();
                $tmp = array("caseId" => $caseSummary['caseId']['id'], "type" => isset($caseSummary['caseId']['type']) ? $caseSummary['caseId']['type'] : '', "userId" => isset($caseSummary['otherParty']['userId']) ? $caseSummary['otherParty']['userId'] : '', "status" => isset($status[0]) ? $status[0] : '', "itemId" => isset($caseSummary['item']['itemId']) ? $caseSummary['item']['itemId'] : '', "transactionId" => isset($caseSummary['item']['transactionId']) ? $caseSummary['item']['transactionId'] : '', "respondByDate" => isset($caseSummary["respondByDate"]) ? $caseSummary["respondByDate"] : '', "creationDate" => isset($caseSummary["creationDate"]) ? $caseSummary["creationDate"] : '', "lastModifiedDate" => isset($caseSummary["lastModifiedDate"]) ? $caseSummary["lastModifiedDate"] : '', "openReason" => isset($caseDetail["openReason"]) ? $caseDetail["openReason"] : '', "decision" => isset($caseDetail["decision"]) ? $caseDetail["decision"] : '', "agreedRefundAmount" => isset($caseDetail["agreedRefundAmount"]) ? $caseDetail["agreedRefundAmount"] : '', "detailStatus" => isset($caseDetail["detailStatus"]) ? $caseDetail["detailStatus"] : '', "initialBuyerExpectation" => isset($caseDetail["initialBuyerExpectation"]) ? $caseDetail["initialBuyerExpectation"] : '');
                $updateSQL = $db->GetInsertSQL($rs, $tmp);
                $db->Execute($updateSQL);
            }
        }
    } else {
开发者ID:speedspeed,项目名称:ebayfeedback,代码行数:31,代码来源:cases_store.php

示例10: importXml

 /**
  * XML 복원파일을 입력받아 기존 데이터를 비우고 DB에 입력한다.
  * @param string $file
  */
 public function importXml($file)
 {
     global $wpdb;
     include 'XML2Array.class.php';
     $xml = file_get_contents($file);
     $array = XML2Array::createArray($xml);
     foreach ($array['kboard'] as $table => $rows) {
         // 테이블에 입력될 데이터가 한 개인지 여러개 인지 확인한다.
         if (isset($rows['data']) && is_array($rows['data'])) {
             $keys = array_keys($rows['data']);
             if (reset($keys) == '0') {
                 $data = $rows['data'];
             } else {
                 $data = $rows;
             }
         } else {
             $data = $rows;
         }
         if ($data) {
             // 테이블 이름에 PREFIX를 추가 한다.
             $table = $wpdb->prefix . $table;
             // 새로 생성될 테이블을 비운다.
             $wpdb->query("TRUNCATE TABLE `{$table}`");
             // 새로운 content를 입력하기 위해서 posts테이블에 입력된 content를 삭제한다.
             if (stristr($table, 'kboard_board_content')) {
                 $wpdb->query("DELETE FROM `{$wpdb->prefix}posts` WHERE `post_type`='kboard'");
             }
             foreach ($data as $key => $row) {
                 $keys = array_keys($row);
                 $row_count = count($row);
                 $columns = array();
                 for ($i = 0; $i < $row_count; $i++) {
                     $columns[] = "`{$keys[$i]}`";
                 }
                 $columns = implode(',', $columns);
                 $value = array();
                 for ($i = 0; $i < $row_count; $i++) {
                     $value[] = "'" . addslashes($row[$keys[$i]]['@cdata']) . "'";
                 }
                 $value = implode(',', $value);
                 $wpdb->query("INSERT INTO `{$table}` ({$columns}) VALUE ({$value})");
                 /*
                  * search 값이 있을경우 post 테이블에 내용을 입력한다.
                  */
                 if (isset($row['search']) && ($row['search']['@cdata'] == 1 || $row['search']['@cdata'] == 2)) {
                     if ($wpdb->insert_id) {
                         $kboard_post = array('post_author' => $row['member_uid']['@cdata'], 'post_title' => addslashes($row['title']['@cdata']), 'post_content' => addslashes($row['secret']['@cdata'] == 'true' || $row['search']['@cdata'] == 2 ? '' : $row['content']['@cdata']), 'post_status' => 'publish', 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_name' => $wpdb->insert_id, 'post_parent' => $row['board_id']['@cdata'], 'post_type' => 'kboard');
                         wp_insert_post($kboard_post, true);
                     }
                 }
             }
             // end foreach
         }
     }
     // end foreach
 }
开发者ID:kimyj9501,项目名称:SingMyStory,代码行数:60,代码来源:KBBackup.class.php

示例11: getProjectConfig

 /**
  * @param string $prj_id
  * @return array
  * @throws AException
  */
 public function getProjectConfig($prj_id)
 {
     $file_name = DIR_EXT . 'developer_tools/projects/dev_tools_project_' . $prj_id . '.xml';
     $xml = file_get_contents($file_name);
     $xml_array = array();
     if ($xml) {
         $xml_array = XML2Array::createArray($xml);
         if (!$xml_array) {
             $this->error[] = 'Cannot convert xml-file ' . $file_name . ' into array. Probably wrong xml syntax.';
         }
         $xml_array = $xml_array['project']['extension'];
         foreach ($xml_array as &$node) {
             if (is_array($node) && isset($node['@cdata'])) {
                 $node = $node['@cdata'];
             }
         }
         // remove item tag from arrays
         $mvcs = array('models', 'views', 'controllers', 'languages');
         foreach ($this->sections as $section) {
             foreach ($mvcs as $mvc) {
                 $item = $xml_array[$mvc][$section]['item'];
                 if (is_array($item) && is_string(key($item))) {
                     $item = array($item);
                 }
                 $xml_array[$mvc][$section] = $item;
             }
         }
     } else {
         $this->error[] = 'Cannot open file ' . $file_name;
     }
     return $xml_array;
 }
开发者ID:hakoobe247,项目名称:developer_tools_extension,代码行数:37,代码来源:developer_tools.php

示例12: ini_set

<?php

if (isset($_SESSION['user_id'])) {
    ini_set("display_errors", 0);
    error_reporting(E_ALL ^ E_NOTICE);
    $pagetitle = "Dashboard";
    $logs = "";
    $res = $db->GetAll("SELECT * FROM `logs` ORDER BY `timestamp` DESC LIMIT 100");
    foreach ($res as $row) {
        $logs .= $row['timestamp'] . ' ' . $row['user'] . ': ' . $row['action'] . chr(13);
    }
    $xml = file_get_contents('quicklinks.xml', true);
    require_once 'xml2array.php';
    $quicklinks = XML2Array::createArray($xml);
    if (isset($_GET['chat'])) {
        $chat_view = 'chat';
    }
    if (isset($_GET['logs'])) {
        $chat_view = 'logs';
    }
    if (!isset($_GET['logs']) && !isset($_GET['chat'])) {
        $chat_view = 'logs';
    }
    ?>

<div id="page-heading">
<?php 
    echo "<title>" . $pagetitle . " - " . $sitename . "</title>";
    echo "<h1>" . $pagetitle . "</h1>";
    ?>
</div>
开发者ID:nsonP,项目名称:DayZAdmin,代码行数:31,代码来源:dashboard.php

示例13: foreach

foreach ($arr['CommonFormat']['Section'] as $n => $spot) {
    if (!empty($spot['xbody'])) {
        $mid = 'tpe-spot-q00-' . $n;
        $mongo->kg->update(array('id' => $mid), array('id' => $mid, 'cat' => 'travel', 'q' => '位於' . $spot['address'] . ' 的 ' . $spot['stitle'] . " 有何特色?", 'a' => $spot['xbody'], 'ts_c' => time(), 'ts_v' => 0, 'img' => empty($spot['file']['img'][0]['@value']) ? null : $spot['file']['img'][0]['@value'], 'location' => empty($spot['latitude']) ? null : array('lat' => $spot['latitude'], 'lon' => $spot['longitude']), 'url' => empty($spot['xurl']) ? null : $spot['xurl']), array('upsert' => true));
    }
    if (!empty($spot['info'])) {
        $mid = 'tpe-spot-q01-' . $n;
        $mongo->kg->update(array('id' => $mid), array('id' => $mid, 'cat' => 'travel', 'q' => '位於' . $spot['address'] . ' 的 ' . $spot['stitle'] . " 該如何前往?", 'a' => $spot['info'], 'ts_c' => time(), 'ts_v' => 0, 'img' => empty($spot['file']['img'][0]['@value']) ? null : $spot['file']['img'][0]['@value'], 'location' => empty($spot['latitude']) ? null : array('lat' => $spot['latitude'], 'lon' => $spot['longitude']), 'url' => empty($spot['xurl']) ? null : $spot['xurl']), array('upsert' => true));
    }
    if (!empty($spot['MEMO_TIME'])) {
        $mid = 'tpe-spot-q02-' . $n;
        $mongo->kg->update(array('id' => $mid), array('id' => $mid, 'cat' => 'travel', 'q' => '位於' . $spot['address'] . ' 的 ' . $spot['stitle'] . " 開放時間為何?", 'a' => $spot['MEMO_TIME'], 'ts_c' => time(), 'ts_v' => 0, 'img' => empty($spot['file']['img'][0]['@value']) ? null : $spot['file']['img'][0]['@value'], 'location' => empty($spot['latitude']) ? null : array('lat' => $spot['latitude'], 'lon' => $spot['longitude']), 'url' => empty($spot['xurl']) ? null : $spot['xurl']), array('upsert' => true));
    }
}
/////////////////////////////
$arr = XML2Array::createArray(file_get_contents('dataset/taipei/travelStayCHINESE.xml'));
foreach ($arr['CommonFormat']['Section'] as $n => $spot) {
    if (!empty($spot['xbody']) && !empty($spot['address'])) {
        $mid = 'tpe-hotel-q00-' . $n;
        $mongo->kg->update(array('id' => $mid), array('id' => $mid, 'cat' => 'travel', 'q' => '位於' . $spot['address'] . ' 的 ' . $spot['stitle'] . " 有何特色?", 'a' => $spot['xbody'], 'ts_c' => time(), 'ts_v' => 0, 'img' => empty($spot['file']['img'][0]['@value']) ? null : $spot['file']['img'][0]['@value'], 'location' => empty($spot['latitude']) ? null : array('lat' => $spot['latitude'], 'lon' => $spot['longitude']), 'url' => empty($spot['xurl']) ? null : $spot['xurl']), array('upsert' => true));
    }
    if (!empty($spot['MEMO_COST'])) {
        $mid = 'tpe-hotel-q01-' . $n;
        $mongo->kg->update(array('id' => $mid), array('id' => $mid, 'cat' => 'travel', 'q' => '位於' . $spot['address'] . ' 的 ' . $spot['stitle'] . " 價位為何?", 'a' => $spot['MEMO_COST'], 'ts_c' => time(), 'ts_v' => 0, 'img' => empty($spot['file']['img'][0]['@value']) ? null : $spot['file']['img'][0]['@value'], 'location' => empty($spot['latitude']) ? null : array('lat' => $spot['latitude'], 'lon' => $spot['longitude']), 'url' => empty($spot['xurl']) ? null : $spot['xurl']), array('upsert' => true));
    }
}
/////////////////////////////
$arr = file('dataset/taipei/臺北市104年度颱風期間開放停車學校概況一覽表.txt');
$schools = array();
$n = 0;
foreach ($arr as $line) {
开发者ID:bryanyuan2,项目名称:pixnet.hackathon.2015,代码行数:31,代码来源:run.php

示例14: Ebay

<?php

require_once 'config.php';
require_once 'lib/ebay.php';
require_once 'lib/cUrl.php';
require_once 'lib/xml.php';
require_once 'lib/imagemagick.class.php';
$ebay = new Ebay($ebayDEVID, $ebayAppID, $ebayCertID, $ebayToken);
$fbNumber = isset($_GET['number']) ? (int) $_GET['number'] : 5;
$feedbacks = XML2Array::createArray($ebay->getFeedBacks($fbNumber));
$feedbacks = isset($feedbacks["GetFeedbackResponse"]['FeedbackDetailArray']['FeedbackDetail']) ? $feedbacks["GetFeedbackResponse"]['FeedbackDetailArray']['FeedbackDetail'] : array();
if (empty($feedbacks)) {
    print_r('error');
    exit;
}
ImageMagick::deleteOldFiles(TEXT_TOOL_TMP_PATH);
$feedbackImages = array();
foreach ($feedbacks as $feedback) {
    $texts = array("str1" => $feedback['CommentText'] . ', ' . date('M-d-y H:i', strtotime($feedback['CommentTime'])), "str2" => $feedback['CommentingUser'] . ' (' . $feedback['CommentingUserScore'] . ')', "str3" => ' ' . $feedback['ItemTitle'] . ' (#' . $feedback['ItemID'] . ')');
    $textImages = array();
    foreach ($texts as $name => $text) {
        $textData = array('font' => "Arial", 'text' => $text, 'size' => 16, 'color' => "black", 'rotate' => 0);
        if ($name == 'str3') {
            $textData['color'] = "gray";
        }
        $textImages[$name] = ImageMagick::createText($textData);
    }
    ImageMagick::addPlus($textImages['str1']);
    ImageMagick::addStar($textImages['str2'], $feedback['CommentingUserScore']);
    ImageMagick::addBorder(TEXT_TOOL_TEXT_PATH . $textImages['str1'], 3);
    ImageMagick::addBorder(TEXT_TOOL_TEXT_PATH . $textImages['str2'], 3);
开发者ID:speedspeed,项目名称:ebayfeedback,代码行数:31,代码来源:feedback.php

示例15: parse_xml_result

function parse_xml_result($result, $xml)
{
    $data = XML2Array::createArray($xml);
    //print_r($xml);
    //	print_r($data['factapi']);
    if (isset($data['factapi']['control']['num_journals']) and $data['factapi']['control']['num_journals'] == 1) {
        $result['journal']['issn'] = $data['factapi']['journallist']['journal']['@attributes']['issn'];
        $result['journal']['title'] = $data['factapi']['journallist']['journal']['title'];
        $result['result_type'] = 'Ok';
    } else {
        $result['result_type'] = 'Error';
    }
    if (isset($data['factapi']['gold']['goldcompliance'])) {
        switch ($data['factapi']['gold']['goldcompliance']['@attributes']['goldcompliancecode']) {
            case 'yes':
                $result['gold']['code'] = 'Yes';
                $result['compilance_type'] = 'Gold';
                break;
            case 'no':
                $result['gold']['code'] = 'No';
                break;
            case 'maybe':
                $result['gold']['code'] = 'Maybe';
                break;
            case 'unknown':
                $result['gold']['code'] = 'Unknown';
                break;
            default:
                $result['gold']['code'] = $data['factapi']['gold']['goldcompliance']['@attributes']['goldcompliancecode'];
        }
        $result['gold']['report'] = $data['factapi']['gold']['goldcompliance']['@attributes']['goldcompliancereport'];
        if (is_array($data['factapi']['gold']['goldreason']) and isset($data['factapi']['gold']['goldreason']['@value'])) {
            $result['gold']['reason'] = $data['factapi']['gold']['goldreason']['@value'];
        } else {
            $result['gold']['reason'] = $data['factapi']['gold']['goldreason'];
        }
        if (isset($data['factapi']['gold']['goldadvicelist']['goldadvice']['@value'])) {
            $result['gold']['advice'] = $data['factapi']['gold']['goldadvicelist']['goldadvice']['@value'];
        }
    }
    if (isset($data['factapi']['green']['greencompliance'])) {
        switch ($data['factapi']['green']['greencompliance']['@attributes']['greencompliancecode']) {
            case 'yes':
                $result['green']['code'] = 'Yes';
                if ($result['compilance_type'] == 'Gold') {
                    $result['compilance_type'] = 'GreenGold';
                } else {
                    $result['compilance_type'] = 'Green';
                }
                break;
            case 'no':
                $result['green']['code'] = 'No';
                break;
            case 'maybe':
                $result['green']['code'] = 'Maybe';
                break;
            case 'unknown':
                $result['green']['code'] = 'Unknown';
                break;
            default:
                $result['green']['code'] = $data['factapi']['green']['greencompliance']['@attributes']['greencompliancecode'];
        }
        $result['green']['report'] = $data['factapi']['green']['greencompliance']['@attributes']['greencompliancereport'];
        if (is_array($data['factapi']['green']['greenreason']) and isset($data['factapi']['green']['greenreason']['@value'])) {
            $result['green']['reason'] = $data['factapi']['green']['greenreason']['@value'];
        } else {
            $result['green']['reason'] = $data['factapi']['green']['greenreason'];
        }
        if (isset($data['factapi']['green']['greenadvicelist']['greenadvice']['@value'])) {
            $result['green']['advice'] = $data['factapi']['green']['greenadvicelist']['greenadvice']['@value'];
        }
    }
    if (isset($data['factapi']['overall']['overallcompliance'])) {
        switch ($data['factapi']['overall']['overallcompliance']['@attributes']['overallcompliancecode']) {
            case 'yes':
                $result['compilance'] = 'Yes';
                break;
            case 'no':
                $result['compilance'] = 'No';
                break;
            case 'maybe':
                $result['compilance'] = 'Maybe';
                break;
            case 'unknown':
                $result['compilance'] = 'Unknown';
                break;
            default:
                $result['compilance'] = $data['factapi']['overall']['overallcompliance']['@attributes']['goldcompliancecode'];
        }
        $result['compilance_report'] = $data['factapi']['overall']['overallcompliance']['@attributes']['overallcompliancereport'];
    }
    return $result;
}
开发者ID:inikoo,项目名称:fact,代码行数:93,代码来源:fact_api.php


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