title: PHP How can I optimise a script?
body: <p><br />
  This script seems to me too long. Is there any way to optimize it?
  <br/> </p>
  
  <pre><code>function delteg($string){
  $keyp=0;
  $out="";
     for ($i=0; $i&lt;strlen($string); $i++) { 
             if ($string[$i]=="&lt;"):
               $keyp=1;
             endif;
  
             if ($keyp==0):
               $out.=$string[$i];
             endif;
  
             if ($string[$i]=="&gt;"):
               $keyp=0;
             endif;
  
     }
     $out = substr($out,0,strlen($out));
     return $out;
  }
  
  $time_step = array();
  $datetime = array();
  $G = array();
  $HHii = array();
  $cloud_cover = array();
  $precipitation = array();
  $pressure = array();
  $temperature = array();
  $humidity = array();
  $wind_direction = array();
  $wind_velocity = array();
  $falls = array();
  $drops = array();
  $n = 0;
  
  $handle = fopen ("http://rp5.ua/xml/257885/en", "r");
  while (!feof ($handle)) {
  $buffer = fgets($handle, 4096); 
  
   if (strpos($buffer, "country_id")&gt;0) ($country_id[$n]=delteg($buffer)); 
   if (strpos($buffer, "point_name")&gt;0) ($point_name[$n]=delteg($buffer));
   if (strpos($buffer, "point_name_trim")&gt;0) ($point_name_trim[$n]=delteg($buffer)); 
   if (strpos($buffer, "point_name2")&gt;0) ($point_name2[$n]=delteg($buffer));
   if (strpos($buffer, "point_timestamp")&gt;0) ($point_timestamp[$n]=delteg($buffer)); 
   if (strpos($buffer, "gmt_add")&gt;0) ($gmt_add[$n]=delteg($buffer)); 
   if (strpos($buffer, "point_date")&gt;0) ($point_date[$n]=delteg($buffer));
   if (strpos($buffer, "point_date_time")&gt;0) ($point_date_time[$n]=delteg($buffer)); 
   if (strpos($buffer, "time_step")&gt;0) ($time_step[$n]=delteg($buffer)); 
   if (strpos($buffer, "datetime")&gt;0) ($datetime[$n]=delteg($buffer));
   if (strpos($buffer, "G")&gt;0) ($G[$n]=delteg($buffer)); 
   if (strpos($buffer, "HHii")&gt;0) ($HHii[$n]=delteg($buffer));
   if (strpos($buffer, "cloud_cover")&gt;0) ($cloud_cover[$n]=delteg($buffer)); 
   if (strpos($buffer, "precipitation")&gt;0) ($precipitation[$n]=delteg($buffer));
   if (strpos($buffer, "pressure")&gt;0) ($pressure[$n]=delteg($buffer)); 
   if (strpos($buffer, "temperature")&gt;0) ($temperature[$n]=delteg($buffer));
   if (strpos($buffer, "humidity")&gt;0) ($humidity[$n]=delteg($buffer)); 
   if (strpos($buffer, "wind_direction")&gt;0) ($wind_direction[$n]=delteg($buffer));
   if (strpos($buffer, "wind_velocity")&gt;0) ($wind_velocity[$n]=delteg($buffer)); 
   if (strpos($buffer, "falls")&gt;0) ($falls[$n]=delteg($buffer));
   if (strpos($buffer, "drops")&gt;0) :($drops[$n]=delteg($buffer));
     $n++;
   endif;
  
  }
  
  fclose ($handle);
  
  for ($i=0; $i&lt;$n; $i++) {
       echo $country_id[$i]." - ".$point_name[$i]. " etc.....";
  
  }
  </code></pre>