2013-03-01 90 views
-3

我正在关注本教程的第二部分,它显示了带有它们下面的描述的图片。 http://www.devtek.org/tutorials/image_gallery.phpPHP图片库描述只显示第一个字母

我遇到了一个问题,我只在.txt文件中放置的描述只会显示第一个字母。我假设数组只读取第一个字母,我可以将其更改为第二,第三和第四个字母,但不是一次读取所有内容。代码在网页上完全相同。

和这里是直播现场我与

www.digifind-it.com/test/script.php

+2

我的水晶球似乎是坏的,请在你的问题中添加一些代码,特别是构建txt文件的te片段 – cernunnos 2013-03-01 20:46:14

+1

欢迎使用堆栈溢出。请直接询问你的问题,不要指望任何人阅读你正在关注的教程,并试图找出你在哪里。 – 2013-03-01 21:04:33

回答

3

改变这一行玩弄

echo '<td align="center"><a href="' . $images . $big . $file . '"><img src="' . $images . $file . '" /></a><br />' . $description[$file][0] . '</td>';

echo '<td align="center"><a href="' . $images . $big . $file . '"><img src="' . $images . $file . '" /></a><br />' . $description[$file]. '</td>';

说明: 当您使用$description[$file][0]你实际上是调用字符串 的第一个字符要显示一个例子尝试你有一个数组$ desription这样

Array 
(
    [] => 
    [PICT0168.JPG] => Balloon Fiesta! 

    [PICT0259.JPG] => Our Halloween Pumpkin 

    [PICT0271.JPG] => Converting our garage to a halloween cave 

    [PICT0282.JPG] => My little ghoulish helpers 

    [PICT0524.JPG] => Ash meets Cinderella on her 7th B-day 

    [PICT0633.JPG] => Jayden's first snowday 

) 

所以:

$string = "Hello World"; 
echo $string[0]; // output H 
+1

这样做!非常感谢,该页面对您的快速响应非常感谢! – user2125063 2013-03-01 20:50:43

+0

@ user2125063下次尝试缩小问题范围并提供一些代码 – HamZa 2013-03-01 20:59:01