Simple chart from <div>s

//array of values
$test = array (35070, 24440, 4730, 35700, 29380, 22860, 28870, 22730, 26270);

//generate chart
echo chart($test, 400);

//function
function chart($array, $size){
	$max = max($array);
	$ratio = $size / $max;
	$out = '';
	
	foreach($array as $element){
		$width = ceil($element * $ratio);
		$out .= "<div class=\"chart\" style=\"width: ".$width."px;\">$element</div>\n";
	}
	
	return $out;
}
		
35070
24440
4730
35700
29380
22860
28870
22730
26270
SESTAVLJANJE KRIĊ½ANK MATJAĊ½ HLADNIK S.P.