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
Re: foreach in reverse [message #174184 is a reply to message #174181] Wed, 25 May 2011 05:11 Go to previous messageGo to previous message
Evolution is currently offline  Evolution
Messages: 14
Registered: April 2011
Karma:
Junior Member
On May 24, 6:40 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> On 5/24/2011 8:43 PM, Evolution wrote:
>
>
>
>
>
>> 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.
>
> http://us3.php.net/manual/en/function.array-reverse.php
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================

Thank you! It worked perfectly!
[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: Fri Sep 20 09:35:22 GMT 2024

Total time taken to generate the page: 0.04053 seconds