我遵循本教程的第二部分,它显示了图片下面的描述。http://www.devtek.org/tutorials/image_gallery.php
我遇到了一个问题,我放在。txt文件中的描述只会只显示第一个字母。我假设数组只读取第一个字母,我可以将其更改为读取第二,第三和第四个字母,但不是一次读取所有字母。网页上的代码完全相同。
这里是我正在使用的live站点
www.digifind-it.com/test/script.php改变这一行
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
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
)
所以当你使用$description[$file][0]
时,你实际上是调用字符串的第一个字符要显示一个示例,试试:
$string = "Hello World";
echo $string[0]; // output H