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.
"You Are Here" script.
Moderator: General Moderators
- daven
- Forum Contributor
- Posts: 332
- Joined: Tue Dec 17, 2002 1:29 pm
- Location: Gaithersburg, MD
- Contact:
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;
?>