本文整理汇总了PHP中xml2array函数的典型用法代码示例。如果您正苦于以下问题:PHP xml2array函数的具体用法?PHP xml2array怎么用?PHP xml2array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xml2array函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getdata
function getdata($style, $parameter)
{
$array = array();
foreach ($parameter as $key => $value) {
if (is_array($value)) {
$parameter[$key] = implode(',', $value);
}
}
$parameter['clientid'] = $this->blockdata['clientid'];
$parameter['op'] = 'getdata';
$parameter['charset'] = CHARSET;
$parameter['version'] = $this->blockdata['version'];
$xmlurl = $this->blockdata['url'];
$parse = parse_url($xmlurl);
if (!empty($parse['host'])) {
define('IN_ADMINCP', true);
require_once libfile('function/importdata');
$importtxt = @dfsockopen($xmlurl, 0, create_sign_url($parameter, $this->blockdata['key'], $this->blockdata['signtype']));
} else {
$importtxt = @file_get_contents($xmlurl);
}
if ($importtxt) {
require libfile('class/xml');
$array = xml2array($importtxt);
}
$idtype = 'xml_' . $this->blockdata['id'];
foreach ($array['data'] as $key => $value) {
$value['idtype'] = $idtype;
$array['data'][$key] = $value;
}
if (empty($array['data'])) {
$array['data'] = null;
}
return $array;
}
示例2: check_patch
public function check_patch($ignore = 0)
{
global $_G;
if (!$ignore && $_G['cookie']['checkpatch']) {
return false;
}
require_once DISCUZ_ROOT . 'source/discuz_version.php';
require_once libfile('class/xml');
$versionpath = '';
foreach (explode(' ', substr(DISCUZ_VERSION, 1)) as $unit) {
$versionpath = $unit;
break;
}
$patchdir = 'http://upgrade.discuz.com/DiscuzX/' . $versionpath . '/';
$checkurl = $patchdir . 'md5sums';
$patchlist = dfsockopen($checkurl);
if (defined('DISCUZ_FIXBUG')) {
C::t('common_patch')->update_status_by_serial(1, DISCUZ_FIXBUG, '<=');
}
if ($patchlist) {
$serial_md5s = explode("\r\n", $patchlist);
$bound = intval(substr($serial_md5s[count($serial_md5s) - 2], 0, 8));
$maxpatch = intval(C::t('common_patch')->fetch_max_serial());
if (defined('DISCUZ_FIXBUG')) {
$maxpatch = $maxpatch < DISCUZ_FIXBUG ? DISCUZ_FIXBUG : $maxpatch;
}
if ($bound > $maxpatch) {
$insertarrlist = array();
foreach ($serial_md5s as $serial_md5) {
$downloadpatch = $patch = '';
list($serial, $md5, $release) = explode(' ', $serial_md5);
if ($serial > $maxpatch && (!$release || in_array(DISCUZ_RELEASE, explode(',', $release)))) {
$downloadpatch = $patchdir . $serial . '.xml';
$patch = dfsockopen($downloadpatch);
if (md5($patch) != $md5) {
continue;
}
$patch = xml2array($patch);
if (is_array($patch) && !empty($patch)) {
$insertarr = array('serial' => intval($patch['serial']), 'rule' => serialize($patch['rule']), 'note' => $patch['note'], 'status' => 0, 'dateline' => $patch['dateline']);
C::t('common_patch')->insert($insertarr);
$insertarrlist[$insertarr['serial']] = $insertarr;
}
}
}
if ($insertarrlist && $_G['setting']['patch']['autoopened']) {
foreach ($insertarrlist as $key => $patch) {
$this->fix_patch($patch);
}
}
if ($insertarrlist) {
C::t('common_setting')->update('showpatchnotice', 1);
include_once libfile('function/cache');
updatecache('setting');
}
}
}
dsetcookie('checkpatch', 1, 60);
return true;
}
示例3: xml2array
function xml2array($xml)
{
foreach ($xml->children() as $parent => $child) {
$return["{$parent}"] = xml2array($child) ? xml2array($child) : "{$child}";
}
return $return;
}
示例4: getLotteriesInfoFromAPI
function getLotteriesInfoFromAPI()
{
global $cfg;
$xml = @file_get_contents($cfg['lottery_api_url']);
$arrLotteries = xml2array($xml);
$arrRet = array();
foreach ($arrLotteries['array'] as $lottery) {
$arrUnit = array();
$arrUnit['currency'] = $lottery['array'][0]['currency'];
$arrUnit['draw-time'] = $lottery['array'][0]['draw-time'];
$arrUnit['id'] = $lottery['array'][0]['id'];
$arrUnit['name'] = $lottery['array'][0]['name'];
$arrUnit['time-zone'] = $lottery['array'][0]['time-zone'];
$arrUnit['date'] = $lottery['array'][1]['array']['date'];
$arrUnit['jackpot'] = $lottery['array'][1]['array']['jackpot'];
$offsetTimezone = getTimezoneOffset($arrUnit['time-zone']);
$lottery_timestamp = strtotime($arrUnit['date'] . ' ' . $arrUnit['draw-time']);
$arrUnit['lottery-base-timestamp'] = $lottery_timestamp;
$arrUnit['lottery-timestamp'] = $lottery_timestamp;
$arrUnit['system-time'] = time() + $offsetTimezone * 3600;
if ($arrUnit['discount-amount'] > 0) {
$arrRet[] = $arrUnit;
}
}
usort($arrRet, 'sortByOrder');
return $arrRet;
}
示例5: xml2array
function xml2array($xmlObject, $out = array())
{
foreach ((array) $xmlObject as $index => $node) {
$out[$index] = is_object($node) ? xml2array($node) : $node;
}
return $out;
}
示例6: import
public function import($s)
{
require_once litepublisher::$paths->lib . 'domrss.class.php';
$a = xml2array($s);
$urlmap = turlmap::i();
$urlmap->lock();
$cats = tcategories::i();
$cats->lock();
$tags = ttags::i();
$tags->lock();
$posts = tposts::i();
$posts->lock();
foreach ($a['rss']['channel'][0]['item'] as $item) {
if ($post = $this->add($item)) {
$posts->add($post);
if (isset($item['wp:comment']) && is_array($item['wp:comment'])) {
$this->importcomments($item['wp:comment'], $post->id);
}
if (!tfilestorage::$disabled) {
$post->free();
}
}
}
$posts->unlock();
$tags->unlock();
$cats->unlock();
$urlmap->unlock();
}
示例7: process_result_stacking
function process_result_stacking($xml_data)
{
$result = array();
$xml_array = xml2array($xml_data);
//debug($xml_array);
if (isset($xml_array['validstack']['unluck'])) {
fianet_insert_log("fianet_sender.php - process_result_stacking() <br />\nError : <br />\n" . $xml_array['validstack']['unluck']['value']);
return $result;
} elseif (isset($xml_array['validstack']['result'])) {
$xml_array = $xml_array['validstack']['result'];
//debug($xml_array);
if (isset($xml_array[0])) {
foreach ($xml_array as $transaction_result) {
$index = count($result);
$result[$index]['refid'] = $transaction_result['attr']['refid'];
$result[$index]['etat'] = $transaction_result['attr']['avancement'];
$result[$index]['details'] = $transaction_result['detail']['value'];
}
} else {
$index = count($result);
$result[$index]['refid'] = $xml_array['attr']['refid'];
$result[$index]['etat'] = $xml_array['attr']['avancement'];
$result[$index]['details'] = $xml_array['detail']['value'];
}
}
return $result;
}
示例8: xml2array
function xml2array($simplexml)
{
if (!is_object($simplexml)) {
return array();
}
$arr = array();
$lastk = '';
foreach ($simplexml as $k => $v) {
$test = array();
$test = xml2array($v);
$ck = (string) $k;
if ($ck == $lastk) {
$cur = count($arr);
if ($cur <= 1) {
$t = $arr[$lastk];
$arr = array($t);
}
$ck = count($arr);
}
if (empty($test)) {
$arr[$ck] = urldecode((string) $v);
} else {
$arr[$ck] = $test;
}
$lastk = (string) $k;
}
return $arr;
}
示例9: xml2array
function xml2array($xml) {
$xmlary = array();
$reels = '/<(\w+)\s*([^\/>]*)\s*(?:\/>|>(.*)<\/\s*\\1\s*>)/s';
$reattrs = '/(\w+)=(?:"|\')([^"\']*)(:?"|\')/';
preg_match_all($reels, $xml, $elements);
foreach ($elements[1] as $ie => $xx) {
$xmlary[$ie]["name"] = $elements[1][$ie];
if ($attributes = trim($elements[2][$ie])) {
preg_match_all($reattrs, $attributes, $att);
foreach ($att[1] as $ia => $xx)
$xmlary[$ie]["attributes"][$att[1][$ia]] = $att[2][$ia];
}
$cdend = strpos($elements[3][$ie], "<");
if ($cdend > 0) {
$xmlary[$ie]["text"] = substr($elements[3][$ie], 0, $cdend - 1);
}
if (preg_match($reels, $elements[3][$ie]))
$xmlary[$ie]["elements"] = xml2array($elements[3][$ie]);
else if ($elements[3][$ie]) {
$xmlary[$ie]["text"] = $elements[3][$ie];
}
}
return $xmlary;
}
示例10: get_data_query_array
function get_data_query_array($snmp_query_id) {
global $config, $data_query_xml_arrays;
include_once($config["library_path"] . "/xml.php");
/* load the array into memory if it hasn't been done yet */
if (!isset($data_query_xml_arrays[$snmp_query_id])) {
$xml_file_path = db_fetch_cell("select xml_path from snmp_query where id=$snmp_query_id");
$xml_file_path = str_replace("<path_cacti>", $config["base_path"], $xml_file_path);
if (!file_exists($xml_file_path)) {
debug_log_insert("data_query", "Could not find data query XML file at '$xml_file_path'");
return false;
}
debug_log_insert("data_query", "Found data query XML file at '$xml_file_path'");
$data = implode("",file($xml_file_path));
$xml_data = xml2array($data);
/* store the array value to the global array for future reference */
$data_query_xml_arrays[$snmp_query_id] = $xml_data;
}
return $data_query_xml_arrays[$snmp_query_id];
}
示例11: run
private function run($action, $xml = '')
{
$this->last_action = $action;
$request = $this->build($action);
$xml = str_replace('[CallerReference]', $request['callref'], $xml);
$this->last_xml = $xml;
// was having problems with wp http, so using staright curl
$ch = curl_init($request['url']);
curl_setopt($ch, CURLOPT_USERAGENT, 'YourMembers CloudFront Lib');
curl_setopt($ch, CURLOPT_HEADERFUNCTION, array($this, 'get_etag'));
if ($this->method == 'POST') {
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
} else {
if ($this->method != 'GET') {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->method);
if ($xml) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
}
}
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $request['headers']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
$this->result = $result;
$data = xml2array($result, 1, 'nottag');
$this->info = $info;
$r = $this->error_handle($data);
if ($r) {
return $r;
}
return $data;
}
示例12: xml2array
function xml2array($xmlContent, $out = array())
{
$xmlObject = is_object($xmlContent) ? $xmlContent : simplexml_load_string($xmlContent);
foreach ((array) $xmlObject as $index => $node) {
$out[$index] = is_object($node) || is_array($node) ? xml2array($node) : $node;
}
return $out;
}
示例13: xml2array
/**
* XML to object
*
* @version 1
* @author Rick de Man <rick@rickdeman.nl>
*
* @param object $xmlObject
* @return object
*/
function xml2array($xmlObject)
{
// Create variable
$result;
// Loop throught object
foreach ((array) $xmlObject as $index => $node) {
// add data
$result[$index] = is_object($node) ? xml2array($node) : $node;
}
// Return results
return $result;
}
示例14: xml2array
function xml2array($xml)
{
$arr = array();
foreach ($xml->children() as $r) {
$t = array();
if (count($r->children()) == 0) {
$arr[$r->getName()] = strval($r);
} else {
$arr[$r->getName()][] = xml2array($r);
}
}
return $arr;
}
示例15: XML2Array
public static function XML2Array($xml)
{
$arr = array();
foreach ($xml as $element) {
$tag = $element->getName();
$e = get_object_vars($element);
if (!empty($e)) {
$arr[$tag] = $element instanceof SimpleXMLElement ? xml2array($element) : $e;
} else {
$arr[$tag] = trim($element);
}
}
return $arr;
}