Originally posted by Weedpacket
And people say I have nothing better to do?!
Originally posted by Merve
Did you use some sort of spider script to read all the files in the manual, and use a regular expression to determine the instances of the 3 words? How many times does 'qux' appear in the manual?
I think I'll answer both of these with a small script:
<?php
// Get the manual into a string
$man = file_get_contents('php_manual_en.html');
// Count how many times these words are repeated
$res[] = array(substr_count($man,"foo"),'foo');
$res[] = array(substr_count($man,"bar"),'bar');
$res[] = array(substr_count($man,"baz"),'baz');
$res[] = array(substr_count($man,"qux"),'qux');
$res[] = array(substr_count($man,"cai"),'cai');
// Draw a cool lookin' 3D box
function drawbox(&$im,$x,$y,$height,$word,&$brightc,&$darkc) {
$bright = array(
$x,$y,
$x,$y-$height,
$x+20,$y-20-$height,
$x+60,$y-20-$height,
$x+40,$y-$height,
$x+40,$y
);
$dark = array(
$x+40,$y,
$x+40,$y-$height,
$x+60,$y-$height-20,
$x+60,$y-20
);
imagefilledpolygon($im,$bright,6,$brightc);
imagefilledpolygon($im,$dark,4,$darkc);
imagestring($im,3,$x,$y,$height*2,imagecolorclosest($im,0,0,0));
imagestring($im,3,$x,$y+10,$word,imagecolorclosest($im,0,0,0));
}
// Our canvas
$im = imagecreatetruecolor(400,300);
imagefill($im,0,0,imagecolorclosest($im,255,255,255));
imagerectangle($im,0,0,399,299,imagecolorclosest($im,0,0,0));
// Allocate some colors
$black = imagecolorclosest($im,0,0,0);
$gray = imagecolorclosest($im,128,128,128);
$red = imagecolorclosest($im,255,0,0);
$darkred = imagecolorclosest($im,128,0,0);
// Set up our grid
imagerectangle($im,45,5,394,255,$gray);
imageline($im,25,25,25,275,$black);
imageline($im,45,255,25,275,$black);
//imagefill($im,30,30,$gray);
for ($i=0;$i<5;$i++) {
imageline($im,45,5+(50*$i),25,25+(50*$i),$black);
imageline($im,46,5+(50*$i),393,5+(50*$i),$gray);
imagestring($im,1,10,20+(50*$i),(6-($i+1)).'00',$black);
imagefill($im,40,100,$gray);
}
imageline($im,25,275,374,275,$black);
imageline($im,394,255,374,275,$black);
imagefill($im,100,260,$gray);
imagerectangle($im,45,5,394,255,$black);
// Draw our 3D boxes
drawbox($im,50,275,$res[0][0]/2,$res[0][1],$red,$darkred);
drawbox($im,120,275,$res[1][0]/2,$res[1][1],$red,$darkred);
drawbox($im,190,275,$res[2][0]/2,$res[2][1],$red,$darkred);
drawbox($im,260,275,$res[3][0]/2,$res[3][1],$red,$darkred);
drawbox($im,330,275,$res[4][0]/2,$res[4][1],$red,$darkred);
// Output image
header('Content-type: image/png');
imagepng($im);
// Destroy
imagedestroy($im);
?>
See the lovely output it generates:

🙂