FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » foreach in reverse
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
foreach in reverse [message #174180] Wed, 25 May 2011 00:43 Go to previous message
Evolution is currently offline  Evolution
Messages: 14
Registered: April 2011
Karma:
Junior Member
I wrote the following code to include a succession of 7 files on my
news page and it works fine. However, if I create a new news brief,
it should be indexed 7 and appear at the top of the page. I am
guessing that I would probably have to use a for loop and not foreach
so that I start with the highest index and decrement down (where
110106_Valentine (below) would be indexed 0), is that the only way?

<?php
session_register();
session_start();
$docRoot = getenv("DOCUMENT_ROOT");

$newsbrief[0] = "110422_Mendes";
$newsbrief[1] = "110411_Livsey";
$newsbrief[2] = "110404_Archuleta";
$newsbrief[3] = "110315_Tanimoto";
$newsbrief[4] = "110312_Ji";
$newsbrief[5] = "110215_Lea";
$newsbrief[6] = "110106_Valentine";

foreach ( $newsbrief as $filename )
{
print " <div class='news'>\n";
require_once $docRoot . '/news/' . $filename . '.php';
print " </div>\n\n";
}
?>

Also, I read somewhere that session_register() and session_start() are
depricated and should not be used. However, when removed them, some
code seems to have stopped working. Below is an example of how I've
been using session_register() and session_start(). What code would
be proper here?

session_register();
session_start();
$html_title="UCSB Earth Science : Home";
$_SESSION['html_title'] = $html_title;

Thanks a bunch.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: problem saving date fields
Next Topic: furniture
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 08:04:07 GMT 2024

Total time taken to generate the page: 0.04440 seconds