A
A
Abc Edc2014-11-17 17:38:23
PHP
Abc Edc, 2014-11-17 17:38:23

Why doesn't the program exit the cycle after parsing xml after the output function?

$result = simplexml_load_file("date.xml");
$i=0;
$mark = array(":", " ", ".");
$max=0;
while ($result){
  $str=$result->str->item[$i]->attributes()->March;
  if ($str == '45'){
      $timeNotFormatted=$result->str->item[$i]->attributes()->TimeNav;
      $time = str_replace($mark, "", $timeNotFormatted);
      $num = ltrim($time, '0');
      $intnum= (int)$num;
      if 	($intnum>$max){
        $max=$num;
      }
     }
  $i++;	
}
echo $max;

does not reach echo $max;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shamanov, 2014-11-17
@gleber1

while ($result) will always evaluate to true

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question