file path [solved]

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
ekosoftco
Forum Contributor
Posts: 108
Joined: Fri Aug 04, 2006 8:21 pm

file path [solved]

Post by ekosoftco »

using

Code: Select all

$_SERVER['PHP_SELF']
is there a way to take off the file extension, the .php part?
i want to be able to show the path the viewer has went through so far, but make it like
/folder/page
instead of /folder/page.php
and a way to make the "/" a "->" instead?
:)
thanks
Last edited by ekosoftco on Wed May 30, 2007 2:50 pm, edited 8 times in total.
ekosoftco
Forum Contributor
Posts: 108
Joined: Fri Aug 04, 2006 8:21 pm

Post by ekosoftco »

never mind, i got it. :)
if anyone wants or needs to know how, here ya go.
these filenames are examples, but its what i use just to let whoever know...

Code: Select all

<?php
	$lineArray = explode('.', $_SERVER['PHP_SELF']);
	$sku = trim($lineArray[0]);
	$skuu = str_replace('/', ' -> ', $sku); //replace / by ->
	echo $skuu;
	?>
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

pathinfo with potentially basename would probably result in a more robust solution. (what happens with file called my.file.php with your solution).
Post Reply