This article mainly introduces PHP regular expressions that replace spaces, line breaks, Chinese commas, and so on with English commas. if you need them, refer to the development process, you may often encounter something that requires someone to provide an input box, and then someone else enters some ID or keyword, such as the wordpress background tag input box:
This is just a comma in the English state. what if someone accidentally enters a comma in the Chinese state? What about decimal point?
So I wrote an expression with a regular expression and replaced the line break with a space with a comma.
Replace the submitted id with a space newline character with a comma, and then use the explode function to switch to an array.
The code is as follows:
$ Ids = $ _ POST ["ID"];
$ Id = preg_replace ("/(\ n) | (\ s) | (\ t) | (\ ') | (,)/",', ', $ ids );
$ Topicids = explode (",", $ tids );
This adds a decimal point filter.
The code is as follows:
$ Ids = preg_replace ("/(\ n) | (\ s) | (\ t) | (\ ') | (,) | (\.) /", ',', $ ids );
OK. after such processing, there will be no problem.
Tip: in fact, it is a better choice for Xiaobian to handle this problem before submitting JavaScript code.