hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : deleting the last element of a string
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

deleting the last element of a string

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 11-15-2002, 08:38 AM
bumpy bumpy is offline
New Member
 
Join Date: Nov 2002
Location: Germany/Blackforest/Furtwangen
Posts: 1
Question

deleting the last element of a string


Hello there!

my question: How do I delete the last element of a string??

i.e.: an url ends like this: .../index.php/
and now I need to trim the last slash otherwise relatively linked images won't load anymore

This problem with the last slash occures when I link to a file that starts a session and gets a variable. then it returns to the page it was loaded from (via $HTTP_REFERER), and at that point it adds a slash to the end...and another one if I reopen it, to change registered variable...and so on.

So is there a possibility to cut this last slash of every time it adds it even without knowing the actual length of - in this case - the url ??

Reply With Quote


Sponsored Links
  #2  
Old 11-15-2002, 01:34 PM
jtrovato jtrovato is offline
Aspiring Evangelist
 
Join Date: Aug 2002
Location: Long Island
Posts: 427
PHP Code:
$variable substr ($variable,0, (strlen($variable)-1) ) 
would this work?

__________________
John Trovato
In Office Networks, LLC
Programmer, Cisco Network Engineer, Roofer, Biochemist, and Conductor.

Reply With Quote
  #3  
Old 11-16-2002, 04:18 PM
MarkIL MarkIL is offline
Aspiring Evangelist
 
Join Date: Jul 2002
Location: Israel
Posts: 351
A shorter version would be

PHP Code:
$t 'abcd';
$t[strlen($t)-1] = ''

__________________
C#/C++/TCL/Python/PHP developer.
mark at mark org il

Reply With Quote
Sponsored Links
  #4  
Old 11-17-2002, 12:00 PM
jtrovato jtrovato is offline
Aspiring Evangelist
 
Join Date: Aug 2002
Location: Long Island
Posts: 427
that's a good one didn't think of that...

John

__________________
John Trovato
In Office Networks, LLC
Programmer, Cisco Network Engineer, Roofer, Biochemist, and Conductor.

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Cloud Business Planning: Hosting, Syndication or Both, with John McMillian Web Hosting News 2013-02-05 18:48:14
Amazon Virginia Data Center Outage Causes Downtime for Reddit, Heroku Web Hosting News 2012-10-23 12:08:06
Rackspace Details New Cloud Hosting Control Panel Features Web Hosting News 2012-08-03 16:03:35
Will ICANN's New gTLD Application System Downtime Affect Web Hosts? Web Hosting News 2012-04-30 16:37:55
Domain Registrar KeyDrive Acquires Moniker and SnapNames from Oversee Web Hosting News 2012-02-03 10:31:27


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?