English 中文(简体)
不能与单纯的xml物体和变数相配?
原标题:could not match simplexml object and variable?

我有一份实验室文件,其中一台Xml文档通过简单的xml装载,并搜寻相应的补贴,所有物品都做罚款,但在将补贴与特定物品相匹配时,它会保 work工作,如果我重复这两种工作的话,就会展示,如果我说要与他们取得对比的话,则使用。

here is my php code

  <?php
error_reporting(E_ALL);
ini_set( display_errors ,  1 );

$cat_xml= simplexml_load_file( http://artstack.com/sites/77/site_categories.xml ); 
$product_xml= simplexml_load_file( http://artstack.com/sites/77/site_products.xml ); 



function getcatid($product_name,$product_xml){
    foreach($product_xml as $product){
        if($product){
            if($product_name==$product->url){
                return $product->cat_id;
            }
        }
    }
}

function getcat($cat_id,$cat_xml){
    foreach($cat_xml as $cat){
        if($cat){
            if($cat_id==$cat->id){
                echo $cat[ name ];
            }
            else{
                if(isset($cat->category)){
                    //sub cat
                    foreach($cat->category as $subcat){
                        if($subcat){
                            echo $cat_id." > ".$subcat->id."<br>";
                            if($cat_id==$subcat->id){
                                echo $cat_id." > ".$subcat->id."<br>";
                                exit;
                            }
                        }
                    }
                }
            }
        }       
    }   
}

getcat(getcatid($_GET[ pro ],$product_xml),$cat_xml);
?>

产出

75 > 73
75 > 74
75 > 75

但这必须

75 > 73
75 > 74
75 > 75
75 > 75
最佳回答

它在使用类型后工作

if(intval($cat_id)==intval($subcat->id)){

THANKS

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签