开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜