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 #174188 is a reply to message #174180] Wed, 25 May 2011 15:07 Go to previous message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma:
Senior Member
On Tue, 24 May 2011 17:43:32 -0700, 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.

Your array appears to be sortable in (reverse) date order.

Try the following in the php cli:

<?php

$newsbrief[] = "110101_oldest";
$newsbrief[] = "110303_newest";
$newsbrief[] = "110202_middle";

rsort($newsbrief);

foreach ($newsbrief as $filename)
{
echo "$filename\n";
}
?>

> Also, I read somewhere that session_register() and session_start() are
> depricated and should not be used.

<http://uk3.php.net/manual/en/function.session-start.php>

Nothing there about session_start being deprecated

session_register is deprecated, see:

<http://uk3.php.net/manual/en/function.session-register.php>

> 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;

Just remove the "session_register();" line. I don't think it does what
you think it is doing here. session_register() is used to register
session global variables.

As far as I can tell, session_register() called _with_no_parameters_
*before* session_start() will just call session_start(), and
session_register() called _with_no_parameters_ *after* session_start()
will do nothing at all.

Use the superglobal $_SESSION[] array instead of registering variables
with session_register().

Rgds

Denis McMahon
[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:41:05 GMT 2024

Total time taken to generate the page: 0.05049 seconds