27.11.2003, 22:07
ich hab noch nen anderes:
<?php
function days_since_date($date){
$date = explode(".", $date);
$timest = mktime("", "", "", $date[1], $date[0], $date[2]);
$days = time() - $timest;
$days = $days / 86400;
return abs(floor($days));
}
// Text und Schriftgröße
$text = array();
$text[] = "In ".days_since_date("24.12.2003")." Tagen ist Weihnachten!";
$font = 5;
$max_len = 0;
foreach($text as $str) {
if(strlen($str)>$max_len) {
$max_len = strlen($str);
}
}
$width = ImageFontWidth($font) * $max_len;
$height = ImageFontHeight($font)*count($text);
$im = imagecreate($width, $height);
$black = ImageColorAllocate ($im, 0, 0, 0);
// Hintergrundfarbe
$white = ImageColorAllocate ($im, 255, 255, 255);
// Schriftfarbe
$orange = ImageColorAllocate ($im, 240, 00, 00);
imagecolortransparent ($im, imagecolorat ($im, 0, 0));
$y = 0;
foreach($text as $str) {
imagestring ($im, $font, 0, $y, $str, $orange);
$y = $y + ImageFontHeight($font);
}
Imagepng($im);
?>
<?php
function days_since_date($date){
$date = explode(".", $date);
$timest = mktime("", "", "", $date[1], $date[0], $date[2]);
$days = time() - $timest;
$days = $days / 86400;
return abs(floor($days));
}
// Text und Schriftgröße
$text = array();
$text[] = "In ".days_since_date("24.12.2003")." Tagen ist Weihnachten!";
$font = 5;
$max_len = 0;
foreach($text as $str) {
if(strlen($str)>$max_len) {
$max_len = strlen($str);
}
}
$width = ImageFontWidth($font) * $max_len;
$height = ImageFontHeight($font)*count($text);
$im = imagecreate($width, $height);
$black = ImageColorAllocate ($im, 0, 0, 0);
// Hintergrundfarbe
$white = ImageColorAllocate ($im, 255, 255, 255);
// Schriftfarbe
$orange = ImageColorAllocate ($im, 240, 00, 00);
imagecolortransparent ($im, imagecolorat ($im, 0, 0));
$y = 0;
foreach($text as $str) {
imagestring ($im, $font, 0, $y, $str, $orange);
$y = $y + ImageFontHeight($font);
}
Imagepng($im);
?>