我想以与该图片链接中显示的方式相同的方式获取结果。我尝试了很多次来获得该解决方案,但无法找到解决此问题的任何方法。图片链接(http://haha123456.hol.es/death/abs2.jpg)
我的 html 代码是:
<html>
<body>
<form action="result.php" method="get">
<input type="text" name="name" id="name">
<input type="button" name="submit" id="submit">
</form>
</body>
</html>
我的 php 代码是:result.php
<?php
header('Content-type: image/jpeg');
$jpg_image = imagecreatefromjpeg('Desert.jpg');
$white = imagecolorallocate($jpg_image, 73, 41, 236);
$font_path = 'OpenSans-Italic.TTF';
$text = $_GET['name'] ;
imagettftext($jpg_image, 25, 0, 75, 50, $white, $font_path, $text);
imagejpeg($jpg_image);
imagedestroy($jpg_image);
?>
而且我还为每个字母表创建了一些数组,但唯一的问题是没有得到正确的命令来拆分作为输入给出的单词,并根据链接图片中给出的每个字母显示数组中的一些单词。
最佳答案
要按字母拆分单词,您可以使用
str_split($str);
要按首字母从某个数组中获取数据,首先,我建议使用
array("a" => "Acrobat","b" => "bull");
等等。
在这种情况下,代码将是:
$arr = array("a" => "Acrobat","b" => "bull");
$result = str_split($str);
foreach ($result as $letter) {
echo $arr[$letter];
}
关于php - 检查每个字母并为每个字母写文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29649374/