removing quotes from a file name......

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
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

removing quotes from a file name......

Post by dull1554 »

i have a seemingly simple question that has turned out to give me some trouble, my question is, is there a way to remove quotes, single or double from a file name before upload???????


i've googled it, i've searced this forum, maybe i'm just not so smart but i can't seem to find a way of doing it short of str_replace or something like that, i just wondered if there was a better way.
User avatar
uberpolak
Forum Contributor
Posts: 261
Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar

Post by uberpolak »

You say that as if there's something wrong with using str_replace... Why not use it?
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

no i never said there was anything wrong with using str_replace, i was mearly looking for a "CLEANER" method, but i'm ready to just breakdown and do it the easy way
User avatar
uberpolak
Forum Contributor
Posts: 261
Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar

Post by uberpolak »

I'm not sure what you mean by cleaner, but I'd just do this:

Code: Select all

<?php
str_replace('"', '', $filename);
str_replace("'", "", $filename);
?>
I'm not sure how that's "dirty." Might be a little confusing to read, due to the massive quotefest going on, but the first line ditches double-quotes, the second single.

I included the code because I thought if you were thinking str_replace wasn't clean you would've been doing it a different way. Unless there's something I don't see happening here.
Post Reply