如何在PHP中创建钟形曲线图 - php

http://support.microsoft.com/kb/213930显示“如何创建钟形曲线图”。我需要用尽可能接近php的东西来自动化它。如果有人可以将我指向一些库/ API等,这将使此操作变得简单,我将不胜感激...

参考方案

如果您不想直接使用GD库制作图表,则可以考虑:
jpgraph和libchart。

我以前用过libchart,但从未画过钟形曲线。

这是jpgraph中的示例,它制作了一种钟形曲线:

<?php
include ("jpgraph/jpgraph.php");
include ("jpgraph/jpgraph_bar.php");
$databary = array();
for ($i=0; $i<32*12; ++$i)
{
    $databary[$i] = 0;
}
for ($i=0; $i<100000; ++$i)
{
    $data = rand(0,31)+rand(0,31)+rand(0,31)+rand(0,31)+rand(0,31)+rand(0,31)+rand(0,31)+rand(0,31)+rand(0,31)+rand(0,31)+rand(0,31)+rand(0,31);
    $databary[$data] += 1;
}
$graph = new Graph(1024,768,'auto');
$graph->SetShadow();
$graph->SetScale("textlin");
$graph->title->Set("Elementary barplot with a text scale");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$b1 = new BarPlot($databary);
$b1->SetLegend("Temperature");
$graph->Add($b1);
$graph->Stroke();

?>

PHP getallheaders替代 - php

我正在尝试从服务器上的apache切换到nginx。唯一的问题是我在PHP脚本中使用的getallheaders()函数,该函数不适用于Nginx。我已经尝试过用户在getallheaders函数上的php站点上提供的注释,但这并不返回所有请求标头。请告诉我如何解决这个问题。我真的想切换到Nginx。 参考方案 您仍然可以使用它,但是您必须像这里一样重新定义…

PHP:将字符串拆分为字母和数字部分的最佳方法 - php

我有几个格式的字符串AA11 AAAAAA1111111 AA1111111 分离字符串的字母和数字部分的最佳方法(最有效)? 参考方案 如果它们都是一系列字母,然后是一系列数字,并且没有非字母数字字符,那么sscanf()可能比regexp更有效$example = 'AAA11111'; list($alpha,$numeric) =…

php-casperjs获取内部文本 - php

我正在为casperjs使用php包装器-https://github.com/alwex/php-casperjs我正在网上自动化一些重复的工作,我需要访问一个项目的innerText,但是我尚不清楚如何从casperjs浏览器访问dom。我认为在js中我会var arr = document.querySelector('label.input…

PHP:检查目录是否为空的最佳和最简便的方法是什么 - php

Improve this question 我有一个包含数百个动态生成文件夹的根目录。随着时间的流逝,在这些目录必须为空的情况下,需要从系统中删除其中一些文件夹。实现这一目标的最佳的最短,最简单和/或最有效的方法是什么? 参考方案 使用glob:if (count(glob("path/*")) === 0 ) { // empty gl…

PHP:从函数返回值并直接回显它? - php

这可能是一个愚蠢的问题,但是……的PHPfunction get_info() { $something = "test"; return $something; } html<div class="test"><?php echo get_info(); ?></div> 有没有办…