所以我有一个数组,它获取随机图像并用某些文本显示它们。不幸的是,文本不会出现,如果出现,超链接不会出现在图像下方。请有人帮忙!!
<?php
define('RANDOM_IMAGES_COUNT', 3);
define('RANDOM_IMAGES_FORMAT', '<img src="%s"><a href="%s"> alt="%s" title="%3$s" style="margin-right:10px"></a>');
#------------------------------------------------------------------------------
$images = array (
array ( 'title' => 'Test 2', 'src' => 'pic2.jpg', 'href' => '<a href=http://mylink.com/path/>Click Me</a>' ),
array ( 'title' => 'Test 3', 'src' => 'pic3.jpg', 'href' => '<a href=http://mylink.com/path/>Click Me</a>' ),
array ( 'title' => 'Test 4', 'src' => 'pic4.jpg', 'href' => '<a href=http://mylink.com/path/>Click Me</a>' )
);
#------------------------------------------------------------------------------
if ( count($images) < RANDOM_IMAGES_COUNT ) {
trigger_error('Not enough images given', E_USER_WARNING);
exit;
}
#------------------------------------------------------------------------------
for ($i = 0; $i < RANDOM_IMAGES_COUNT; $i++) {
shuffle($images);
$tmp = array_shift($images);
printf( RANDOM_IMAGES_FORMAT, $tmp['src'],$tmp['href'], $tmp['title'] );
}
?>