2010-03-09 71 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