in string spec. symbol, php
how to see in string开发者_JAVA百科 all spec symbols?
Examples: space, new line, tab and t.t
I dont know exactly, what you mean by "see".
You can use preg_match_all() with the *PREG_OFFSET_CAPTURE* -Flag and you will get any occurence. You can then use this to do, what you like. If you really just want to see "something", use Pekkas solution.
$string = str_replace(array("\t","\n"," "),array('<TAB>','<NEWLINE>','<SPACE>'), $string);
Its exactly the same, but in one call.
Update: addcslashes()
$string = addcslashes($string, "\n\t\r ");
You can use str_replace()
to make the characters of your choice visible:
$string = "Insert here a string that contains spaces, newlines, tabs";
$string = str_replace("\t", "<TAB>", $string);
$string = str_replace("\n", "<NEWLINE>", $string);
$string = str_replace(" ", "<SPACE>", $string);
精彩评论