Member Avatar for mehnihma

I have this code:

$status_kol=trim($v->Status);
$mojakolicina = "Raspoloživo";

if($status_kol=="Raspoloživo"){

$status_dobavljivosti=2;

    }
    else {

        $status_dobavljivosti=0;
         }

         echo "OVO JE ZA dostupnost : $status_dobavljivosti <br/>\n";

But i alway get 0 And I get 3 when status_kol is not "Raspoloživo"?

Can you help me with this?

Thans

Member Avatar for diafol

Works fine for me - I get 0 (false) and 2 (true).

Member Avatar for mehnihma

All the time I get when 0 never 2 for Raspoloživo
I dont get it
And when I print out lenght of string $v->Status I get 12 but it is 11?

Member Avatar for mehnihma

There is somewhere worng encoding set in my php, but I cannot get where

Member Avatar for mehnihma

I am getting worng encoding here I think but why?

    foreach($xml as $k=>$v){
        $b="";
        if($i==0){
            foreach($v as $k1=>$v1){
                $head[]=$k1;
            }
            array_push($head,"meta_description","meta_tag","tax","supplier","quantity","price");
            foreach($head as $k4=>$v4){
                $b.= "$v4".DELIMITER;
            }
        }//echo $xml->$k->BrojArtikla."=>".$xml->$k->Image."<pre>".print_r($head,1)."</pre>";
        foreach($head as $k3=>$v3){
            if($v3=='meta_description'){$v3='Naziv';}

            if(empty($v->$v3) or $v->$v3=="" or !isset($v->$v3)){
                $v->$v3="|||";
            }
            if($v3=='tax'){
                $b.=TAX.DELIMITER;
                $v->$v3=TAX;
            }elseif($v3=='supplier'){
                $b.=$supplier_name.DELIMITER;
                $v->$v3=$supplier_name;
            }elseif($v3=='quantity'){
                if($v->Status=='Raspoloživo'){
                //if($v->Status=='Raspoloživo'){
                    $b.="2".DELIMITER;
                    $v->$v3=2;
                }else{
                    $b.="0".DELIMITER;
                    $v->$v3=0;
                }
Member Avatar for diafol

Here you say $v is an array:

foreach($v as $k1=>$v1){
   $head[]=$k1;
}

Then it's an object:

$v->$v3

Is it both?? Confused.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.