All pastes #535151 Raw Edit

Someone

public text v1 · immutable
·published 2007-06-04 00:42 UTC
rendered paste body
$file = "mdMetrics.xml" ;
$handle = fopen($file, "r") ;
$i = 1 ;
$mdIB = array() ;
$IB = array() ;

while(!feof($handle))	{
	$l = fgets($handle) ; ;
	if(strstr($l,"<TEAM>MDIB</TEAM>"))	{ //Gets us to the MD IB Team section.
		$garbage_line = fgets($handle) ; //Catches <LIST_G_DETAILS>.	
		while(!feof($handle))	{
			$garbage_line = fgets($handle) ; //Catches <G_DETAILS>.
			if(strstr($garbage_line, "</LIST_G_DETAILS>"))	{ //Kills process, end of reps.
				break ;
			}
			$l3 = fgets($handle) ; //Grabs first line of cycle.
			while(!strstr($l3, "</G_DETAILS>"))	{ //Catches end of a specific rep's stats.
				$l3 = ltrim(rtrim($l3)) ; //String manipulation to extract category for array key.
				$l3 = substr(str_replace(array("<", ">"), ",", $l3), 1) ;
				$l3 = explode(",", $l3)	;
				$mdIB[$i][$l3[0]] = $l3[1] ;
				$l3 = fgets($handle) ;
			}
			$i++ ;
		}
	}
}
//Reorganize the array to reflect [REP][STAT]
foreach($mdIB as $v)	{
	foreach($v as $k => $n)	{
		if($k == "EXTERNALUSERID")	{
			$IB[$n] = array() ;
			reset($v) ;
			foreach($v as $ki => $nm)	{
				$IB[$n][$ki] = $nm ;
			}
		}
	}
}