[thelist] PHP String Indexed Arrays

Jacob Aust mail_lists at jakesdiner.com
Fri Jun 7 01:24:00 CDT 2002


Well...

I am using the string indexed arrays because this array (an others like it)
represent sections of my web site. I plan to use the Index as a GET variable
appended to the URL to request a section. In other words, if I want the
"case studies" section, I will request "index.php?section=case"

I am using the array to print out the navigation between sections and the
Index to identify which section I am currently in (based on the GET
variable) so that I can bold that when I write it to HTML as an indicator of
the current section.

Thanks for the code...I'll try it now.

Jake




On 6/6/02 11:17 PM, "Shashank Tripathi" <sub at shanx.com> wrote:

> Jacob,
>
> Try this somewhat kludgish code. But in general, I wonder why you really
> need to work with the string arrays anyway!
>
> Cheers,
> Shashank
>
>
> ---------
>
> <?php
>
> $myhref = "index.php";
> $sections = array ("case" => "case studies", "client" => "by client",
> "type"=> "by type");
> print_r($sections);
> echo "<p>";
>
> global $sections;
> global $myhref;
> echo"<p class=\"subWORK\"> ";
>
> $ctr = 0;
> foreach ($sections as $sectionID => $section)
> {
>
>   $ctr++;
>   echo"<a href=\"$myhref?$sectionID\"> $section</a> ";
>   if ($ctr <> sizeOf($sections))
>   {
>       echo" // ";
>   }
>
> }
>
>
>
> ?>




More information about the thelist mailing list