rernanded
Erfahrenes Mitglied
Wie kann ich am besten alle Zeilen in einer .txt in images wandeln und sofort anzeigen?
Hier mein Code der leider nur die letzte Zeile umwandelt.
MONI
Hier mein Code der leider nur die letzte Zeile umwandelt.
MONI
PHP:
<form method="post" action="txt2img.php" enctype="multipart/form-data">
<input type="text" name="text1" size="100">
<input type="submit" value="los">
</form>
<?php
$fn = fopen("test.txt","r");
while(! feof($fn)) {
$result = fgets($fn);
foreach (array($result) as $wow) {
//echo $wow."<br />";
//$text = $_POST["text1"];
$text = $wow;
// (A) NEW EMPTY IMAGE OBJECT
// imagecreate(WIDTH, HEIGHT)
$img = imagecreate(150, 80);
// (B) SET COLORS
// imagecolorallocate(IMAGE, RED, GREEN, BLUE)
$red = imagecolorallocate($img, 255, 0, 0);
$white = imagecolorallocate($img, 255, 255, 255);
// (C) EMPTY RED RECTANGLE
// imagefilledrectangle(IMAGE, START X, START Y, END X, ENDY, COLOR)
imagefilledrectangle($img, 0, 0, 150, 80, $red);
// (D) WRITE TEXT
// imagestring(IMAGE, FONT, X, Y, TEXT, COLOR)
// FONT is a number 1 to 5. 1 is smallest font size, 5 is biggest.
imagestring($img, 5, 10, 10, $text, $white);
// (E) SAVE TO FILE
// imagepng(IMAGE, TARGET FILE)
imagepng($img, "twitter_members_images/$text.png");
imagedestroy($img); // OPTIONAL
}
}
fclose($fn);
?>