Burada PHP programlama acemi. Ben dizilerle ilgili bazı soru var. Nasıl bir dizi bitişik değerleri arasındaki fark alabilirim?
$value = array(2, 5, 9, 10, 19);
How do I get the difference between the 2 and 5? Then 9 and 5? Then 10 and 9, then 19 and 10? The reason I want to get the difference is to draw a stack graph. And each stack will depend on each difference.
Update:
Merhaba, tamamen bu bir kayıp üzgünüm beyler. O bunu ben istiyorum şekilde yapamaz gibi görünüyor. here istiyorum benzer yığılmış grafiği görmek için tıklayınız. Ben yığılmış grafik çizmek zaman otomatik olarak kendi değerine ayarlamak böylece nasıl benim diziler için bir ölçek oluşturabilirim?
İşte ben kullanmaya çalışıyorum kodudur.
<?php
$img_width=200;
$img_height=425;
$img=imagecreatetruecolor($img_width,$img_height);
$bar_color=imagecolorallocate($img,0,64,128);
$line_color=imagecolorallocate($img,220,220,220);
imagefilledrectangle($img,$x1,$y1,$x2,$y2,$bar_color);
$value = array(116,160,210,269,325,425);
for ($i = 1, $n = count($value); $i < $n; $i++) {
$diffs[] = $value[$i] - $value[$i-1];
imageline($img,0,$value[$i]-$value[$i-1],$img_width,$value[$i]-$value[$i-1],$line_color);
}
header("Content-type:image/png");
imagepng($img);
?>
Ben tüm yardım için teşekkür ederiz.