2010-03-09 45 views
1

考虑以下几点:快速的PHP问题导致

$img_pathm = JURI::root().'images/properties/images/'.$this->datos->id.'/'; 
$peque_path = JURI::root().'images/properties/images/thumbs/'.$this->datos->id.'/'; 

$result = count($this->Images); 
$resultf = $result-1; 

while ($resultf>=0){ ?> 

<span class="editlinktip hasTip" title="<?php echo $this->datos->image1;?>:: 

<img border=&quot;1&quot; src=&quot;<?php echo $peque_path.$this->Images[$resultf]->name; ?>&quot; name=&quot;imagelib&quot; alt=&quot;<?php echo JText::_('No preview available'.$img_pathm); ?>&quot; width=&quot;206&quot; height=&quot;100&quot; />"> 

<img src="<?php echo $peque_path.$this->Images[$resultf]->name; ?>" alt="Additional image <?php echo $resultf+1 ?>" width="65px" height="50px"/></span> <?php 

$resultf--; } 

目前这打印图像一前一后。我需要做的就是颠倒这些图像打印给用户的顺序。我不知道在哪里,或者我该如何在此代码中插入类似于ORDER的东西?提前致谢!

回答

1

只是循环的其他方式:

$img_pathm = JURI::root().'images/properties/images/'.$this->datos->id.'/'; 
$peque_path = JURI::root().'images/properties/images/thumbs/'.$this->datos->id.'/'; 

$result = count($this->Images); 
$resultf = 0; 

while ($resultf<$result){ ?> 

<span class="editlinktip hasTip" title="<?php echo $this->datos->image1;?>:: 

<img border=&quot;1&quot; src=&quot;<?php echo $peque_path.$this->Images[$resultf]->name; ?>&quot; name=&quot;imagelib&quot; alt=&quot;<?php echo JText::_('No preview available'.$img_pathm); ?>&quot; width=&quot;206&quot; height=&quot;100&quot; />"> 

<img src="<?php echo $peque_path.$this->Images[$resultf]->name; ?>" alt="Additional image <?php echo $resultf+1 ?>" width="65px" height="50px"/></span> <?php 

$resultf++; } 
+0

谢谢,就是这样! – skarama 2010-03-09 18:47:06

0

也许你可以使用array_reverse

+0

虽然这种联系可以回答这个问题,最好是在这里有答案的主要部件,并提供链接参考。如果链接页面更改,则仅链接答案可能会失效。 – Jocelyn 2012-08-23 22:02:15

+1

@Jocelyn我同意,但这是官方PHP手册的链接。但是你正在审查的好东西。 – fancyPants 2012-08-24 10:59:24