A dynamic pie chart in PHP
<?php

    define
("WIDTH"450);
    
define("HEIGHT"450);

    
$piegraph_data = array (10520401015);
    
    
$img imagecreate(WIDTHHEIGHT);
    
    
$background $white imagecolorallocate($img0xFF0xFF0xFF);
    
$black imagecolorallocate($img000);
    
    
$center_x = (int)WIDTH/2;
    
$center_y = (int)HEIGHT/2;
    
    
imagerectangle($img00WIDTH-1HEIGHT-1$black);
    
    
$last_angle 0;
    
    foreach(
$piegraph_data as $percentage) {
        
$arclen = (360 $percentage) / 100;
        
imagefilledarc($img,
                       
$center_x,
                       
$center_y,
                       
WIDTH-20,
                       
HEIGHT-20,
                       
$last_angle,
                       (
$last_angle $arclen),
                       
imagecolorallocate($imgrand(00xFF), rand(00xFF), rand(00xFF)),
                       
IMG_ARC_PIE);
        
$last_angle += $arclen;
    }

    
header("Content-Type: image/png");
    
imagepng($img);


?>