preg_replace patterns

I am using preg_replace to remove spaces in a file name and add %20 so I can display it as a web link. I had a file that had a # sign somehwere in the name and when it tried to display file it couldn’t. I tried several different patterns to eliminate the # sign, but they didn’t work. Any thoughts on a pattern to eliminate the # sign?

Thank you for your help.

[php]foreach (glob("…/*.pdf") as $filename) {

$file_name2 = preg_replace("/ /", “%20”, $filename);

ECHO “<a href=$file_name2 target=”_blank" >Report
";[/php]

why not use str_replace;
[php]$filename = str_replace(’ ', ‘%20’, $filename);[/php]

Simples!

Red :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service