You are here: Re: str_ireplace problems. « PHP « IT news, forums, messages
Re: str_ireplace problems.

Posted by Gustavo Narea on 11/02/05 02:27

Daniel Spain wrote:
> //Remove the drive letter and replace it with a single slash
> $step1 = str_ireplace("T:\\", "\\", $_POST['path']);

I would use:
$step1 = ereg_replace(trim("^[:alpha:]"),"",$_POST['path']);

This will remove the first letter of the string. You should use this,
unless this letter is "T" forever. As far as I can see, this is for
Windows, and the letter may change depending on the machine.

On the other hand, you should verify that the user is sending you a
right path.

The instruction I suggested you is based on Regular Expressions. If you
want to get more information about them, I suggest you:
http://www.regular-expressions.info

PS: If get_magic_quotes_gpc() returns true, you should use
stripslashes() too:
$step1 = ereg_replace(trim("^[:alpha:]"),"", stripslashes($_POST['path']));

--
Best regards,

Gustavo Narea.
PHP Documentation - Spanish Translation Team.
Valencia, Venezuela.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация