有两个数组。一个洗牌图像,另一个没有洗牌。当你去到网站时,它应该以随机顺序显示图像。这样可行。现在,如果您从这个其他域转发,而不显示其他数组,则我希望它。如果是域,则显示此数组
这里是我的数组没有洗牌:
<?
$items1 = array(
array('image'=>'/images/logos/1.png', 'link' => 'http://www.blah.com', 'text' => 'blah'),
array('image'=>'/images/logos/2.png', 'link' => 'http://www.blah.com', 'text' => 'blah'),
array('image'=>'/images/logos/3.png', 'link' => 'http://www.blah.com', 'text' => 'blah'),
array('image'=>'/images/logos/4.png', 'link' =>
);
?>
这里是我想的,如果else语句,以显示正确的数组:
<?php $domain = "http://www.blahblah.com";
if ($domain == blahblah.com)
{ echo '<?foreach($items1 as $i1){?>
<div>
<a href="<?=$i1['link'];?>"><img width="400" height="200" src="<?=$i1['image'];?>"></a>
</div>
<? } ?>'; }
else
{ echo '<?foreach($items as $i){?>
<div>
<a href="<?=$i['link'];?>"><img width="400" height="200" src="<?=$i['image'];?>"></a>
</div>
<? } ?>'; }
?>
引导我到光的人!由于
greg0ire>代码的建议:
<?php $domain = "http://www.blahblah.com";
if ($domain == "http://www.blahblah.com"):// use alternative syntax in templates
foreach($items1 as $i1): // do not try to "echo 'foreach'" ?>
<div>
<a href="<?=$i1['link'];?>"><img width="400" height="200" src="<?=$i1['image'];?>"></a>
</div>
<?php
endforeach;
else:
foreach($items as $i):?>
<div>
<a href="<?=$i['link'];?>"><img width="400" height="200" src="<?=$i['image'];?>"></a>
</div>
<?php
endforeach;
endif;?>