substr() question

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
User avatar
Sevengraff
Forum Contributor
Posts: 232
Joined: Thu Apr 25, 2002 9:34 pm
Location: California USA
Contact:

substr() question

Post by Sevengraff »

How can remove the last 4 characters from the value of a variable???
example:
i have a variable with the value of "index.inc"
I want to remove the .inc from the end, so that the value is "index"
Im told substr() can do this, but when i use it like this:

Code: Select all

$file = substr("$viewFile", 0, -4);
($file is just $viewFile without the .inc) it doesn't work.
Can anyone help?
User avatar
Sevengraff
Forum Contributor
Posts: 232
Joined: Thu Apr 25, 2002 9:34 pm
Location: California USA
Contact:

Post by Sevengraff »

never mind, i got it to work. Thanks anyway!
Post Reply