"You Are Here" script.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Skyzyx
Forum Commoner
Posts: 42
Joined: Fri Feb 14, 2003 1:53 am
Location: San Jose, CA

"You Are Here" script.

Post by Skyzyx »

I'm new to PHP, so my knowledge of it is limited. However, I'm fluent in JavaScript, so I should be able to grasp parallel functions between the two languages.

I'm trying to write a simple "you are here" script in PHP based on the directories listed in the URL. I'd like to be able to optionally give directories different "showing" names than the actual name of the directory.

I wrote one in JavaScript, but it uses innerHTML, and some browsers (not naming any names, Opera) don't support it as well as I'd like (or at all).

It'd be cool if someone had one lying around that I could use. If not, does anyone have a link that I could check out some source code?

Other than that, I'd be willing to write my own, but I'd need to know some parallel functions in PHP for JavaScript.

- String.indexOf();
- String.split();
- single-dimensional array syntax

I think I'd fare pretty well if someone could give me a "boost" on these.

Thanks.

p.s. Also, I need to know how to include a separate PHP script file as you would with .js files.
macewan
Forum Commoner
Posts: 97
Joined: Mon Jul 07, 2003 8:27 pm

Post by macewan »

ah. a fellow believer in standards!!
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post by daven »

Code: Select all

<?php
String splitting
  split(), explode(), or preg_split()

Arrays:
  #pre-defined:  
    $my_arr=array("item1","item2"); // automatically uses integer index
    $my_arr=array(0=>'value1',1=>'value2');  // specify indexes
    $my_arr=array('key1'=>'value1','key2'=>'value2');  // use keys, like a hash
  #dynamic or set later
    $my_arr=array();  $my_arr[0]='value1';  $my_arr[1]='value2';
    $my_arr=array();  $my_arr['key1']='value1';  $my_arr['key2']=value2;
?>
Sorry, I don't remember what string.indexOf does, so I cannot offer a suggestion for a replacement
Post Reply