Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strip characters?

Status
Not open for further replies.

rrsub

MIS
Joined
Oct 23, 2002
Messages
536
Location
US
I'd thought this would be an easy find on Google and PHP but I'm still stuck.

Newbie and I'm trying to strip characters from my variables.

I have a directory where the names are xxxxx.com and xxxxx.edu and xxxxx.org. I need to have xxxxx as the value.

I thought rtrim($text, ".com"); would work. What's the alternative?
 
look up the string functions of PHP in the manual....

I found these:
parse_url()
substr()
explode()

The common way to do this is to use substr() and then use another method that will locate the integer position of the occurrence of a seperator -- so u could use strripos() which finds the LAST occurrence of say '.' and then plug in the return value into the substr() function and thusly get a value stripped of '.com','.org',etc...

Rocco is the BOY!!

SHUT YOUR LIPS...
ROCCOsm.gif
 
or the split() function or the eregi_replace() functions...

Known is handfull, Unknown is worldfull
 
eregi_replace() works great!

$file = eregi_replace(".com","",$dir);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top