Input: The input is read from a text file: while ($data = FGets($soubor)) { ... }
.
Output: I would like to safe content to DB (import) without \t
.
I think, that it offers an alternative for trim:
while () ...
$editedText = trim($data, "\t");
I need \t, and check in whole txt document. Any suggestions and samples?
What is the best way for this easy task without RE?
The str_replace()
function is your new best friend.
$editedText = str_replace(array("\t", "
"), "", $data);
strtr
: http://www.php.net/manual/en/function.strtr.php
strtr($s, array(""=>" ", " "=>" ", "\t"=>" "));
str_replace
: http://www.php.net/manual/en/function.str-replace.php
see other answer
I use
s.trim();
it helps to lose whiteSpace, , \t and so on from both ends of the string.