RE: [PHP4BETA] re:array navigation
[email protected] ("Dan") Sat, 10 Jun 2000 10:44:34 -0400
| Newsgroups | php.version4 |
|---|---|
| Message-ID | <000701bfd2ea$65665a10$0200a8c0@dans_nt_400.savage-comedy.com> |
Isolate your file name and use associative arrays for your values.
$Next[ "zero" ] = "one.htm";
$Next[ "one" ] = "two.htm";
Then use $Next[ $filename ] to get the value.
Here's a function to isolate the filename (no extension), called using the
"macro" for the filename (which included the path)
$filename = JustFileName( __FILE__ );
function JustFileName( $pathAndFile )
{
$basename = basename( $pathAndFile );
$pos = strrpos($basename, "." );
if ($pos)
return substr( $basename, 0, $pos );
else
return $basename;
}
Dan Sevush
CTO Dan's Chocolates
www.danschocolates.com
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of Joseph H Blythe
> Sent: Friday, June 09, 2000 1:40 AM
> To: php4
> Subject: [PHP4BETA] re:array navigation
>
>
> Hi all,
>
> I had an idea (wow), what i would like to do is store all the pages in
> my site in an array inside an include file:
>
> $Nav = array(
> "0" => "zero.htm",
> "1" => "one.htm",
> "2" => "two.htm",
> "3" => "three.htm");
>
> $Next = next($Nav);
> $Prev = prev($Nav);
>
> then have links on each page and of course include the file that
> contains the Nav array
>
> echo "<a href='$Next'>Next</a> <a href='$Prev'>Prev</a>";
>
> and of course this doesnt work as it will always point to:
>
> $Next = one.htm
> $Prev = zero.htm
>
> I have tried all sorts of thins using pos() and current() to
> no success.
>
> has anyone every tried to do something simular to this type of
> navigation, or am I just plain mad.
>
> Any help would be great.
>
>
> Joseph Blythe
>
> --
> BoldFX / Binary Logic
> 257 Churchill Road Prospect South Australia 5082
> Ph: (08) 8342 0022 Fax: (08) 8342 0155
> mailto: [email protected]
>
>
>
>
> --
> PHP 4.0 Beta Mailing List <http://www.php.net/version4/>
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> To contact the list administrators, e-mail:
> [email protected]
>