Jump to content


Photo

How Can I Delete the .php in my echo statement?


  • Please log in to reply
4 replies to this topic

#1 bigthink

bigthink
  • New Members
  • Pip
  • Newbie
  • 5 posts
  • LocationOKC, OK

Posted 28 October 2006 - 04:16 PM

Ok, so here's the new problem.  The frustrating thing is I had the answer and then accidentally deleted it!  ARGH.


Anyway this is what I have:

<?
                        $fullpath = $_SERVER["PHP_SELF"];
                        $filename = substr(strrchr($fullpath, "/"), 1);
                        echo $filename

?>


When it echos the $filename it prints out : pagename.php

How can I echo just "pagename" without the .php tag?

Your help is always appreciated and I'll keep looking in the meantime!



#2 bigthink

bigthink
  • New Members
  • Pip
  • Newbie
  • 5 posts
  • LocationOKC, OK

Posted 28 October 2006 - 04:47 PM

I think everytime I have a problem I'm just going to immediately come post in here because within minutes of posting I ALWAYS find the answer.

In case you are wondering, too:
<?

                        $clean = explode("/",$_SERVER["SCRIPT_NAME"]);
                        $clean=explode(".",$clean[1]);
                        $clean=$clean[0];
                        echo $clean;


?>

That will do it again!

#3 bigthink

bigthink
  • New Members
  • Pip
  • Newbie
  • 5 posts
  • LocationOKC, OK

Posted 28 October 2006 - 04:57 PM

Nevermind...still looking for an anwer.  :(

That just gives me part of the page title.  What in the heck?


Anyone have an answer that works? :)

#4 Skatecrazy1

Skatecrazy1
  • Members
  • PipPipPip
  • Advanced Member
  • 126 posts
  • LocationSouthern California

Posted 28 October 2006 - 05:08 PM

wow this is simple. don't make posts every 10 minutes just because you haven't gotten an answer yet. try something like this.

<?php
$string = "filename.php";
$string = rtrim($string, ".php");
echo $string;
?>

i tested that and it worked.
fuck it or fight it

#5 brendandonhue

brendandonhue
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts

Posted 28 October 2006 - 07:28 PM

Or
$string = basename('filename.php', '.php');





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users