when if statement using php while checking values xml file, thinks statement not true although is..
<?xml version="1.0" encoding="utf-8" standalone="yes"?> <tacviewdebriefing version="1.2.6"> <mission> <title>tape0003</title> <missiontime>2015-06-03t00:00:00z</missiontime> <duration>32890.02</duration> <mainaircraftid>59</mainaircraftid> </mission> <events> <event> <time>32224.76</time> <primaryobject id="59"> <type>aircraft</type> <name>f-16c fighting falcon</name> <pilot>viper</pilot> <coalition>rok/shark</coalition> </primaryobject> <action>hastakeoff</action> <airport id="icao:llhs"> <name>hatzor afb</name> </airport> </event> </events> </tacviewdebriefing> and sample of code:
$xml = simplexml_load_file($filedir) or die("error: not open file<br>"); if(isset($xml->mission)){ foreach($xml->events->event $value){ $num++; if($xml->mission->mainaircraftid === $value->primaryobject['id']{ echo $value->action; } } } p.s: if try echo $value->primaryobject['id'];
, echo $xml->mission->mainaircraftid; (inside foreach loop)
prints 59 , 59...
eventually took mark baker's advise , made if statement this: if((string)$value->primaryobject['id'] === (string) $xml->mission->mainaircraftid) thank guys.
Comments
Post a Comment