Re: foreach sorting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



when the if statement is true how do i make it appear as the last record in
the loop?

$tabarray = array('/games' => 'Games', '/news' => 'News');

foreach ($tabarray AS $loc => $item)
{
 if(strpos($loc, $_SERVER['REQUEST_URI']) !== false)
 {
  $tabmenulist .= '<td class="tabsel"><a href="'.$loc.'">'.$item.'</a></td>
 }
 else
 {
  $tabmenulist .= '<td class="tabdel"><a href="'.$loc.'">'.$item.'</a></td>
 }
}


this should work if I understand you correctly...


$tabarray = array('/games' => 'Games', '/news' => 'News');

foreach ($tabarray AS $loc => $item)
{
 if(strpos($loc, $_SERVER['REQUEST_URI']) !== false)
 {
  $last_tabmenulist = '<td class="tabsel"><a href="'.$loc.'">'.$item.'</a></td>
 }
 else
 {
  $tabmenulist .= '<td class="tabdel"><a href="'.$loc.'">'.$item.'</a></td>
 }
}

$tabmenulist .= $last_tabmenulist;

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux