Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #1833
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: foreach in reverse |
| Date | 2011-05-24 21:40 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <irhmn8$6qt$1@dont-email.me> (permalink) |
| References | <54289e0b-89c3-4bc5-9077-77a2568b66fe@q12g2000prb.googlegroups.com> |
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.
jstucklex@attglobal.net
==================
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
foreach in reverse Evolution <cryptozoan@gmail.com> - 2011-05-24 17:43 -0700
Re: foreach in reverse Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-24 21:40 -0400
Re: foreach in reverse Evolution <cryptozoan@gmail.com> - 2011-05-24 22:11 -0700
Re: foreach in reverse sheldonlg <sheldonlg@thevillages.net> - 2011-05-26 07:59 -0400
Re: foreach in reverse Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-24 21:44 -0400
Re: foreach in reverse "Peter H. Coffin" <hellsop@ninehells.com> - 2011-05-24 21:01 -0500
Re: foreach in reverse Helmut Chang <usenet@helmutchang.at> - 2011-05-25 08:05 +0200
Re: foreach in reverse Helmut Chang <usenet@helmutchang.at> - 2011-05-25 08:19 +0200
Re: foreach in reverse Denis McMahon <denis.m.f.mcmahon@gmail.com> - 2011-05-25 15:07 +0000
csiph-web