PHP form inserting
at the end of the text on each submission to MSSQL

后端 未结 1 1698
没有蜡笔的小新
没有蜡笔的小新 2021-01-26 13:39

Hi everyone I had previously posted about a
getting inserted at the beginning of my text and we got that fixed. (here is my previous post with the code)

1条回答
  •  终归单人心
    2021-01-26 14:09

    This should do it, matches
    ,
    or
    at the start or end:

    preg_replace('#^|$#i', "\n", $str);
    

    The tag is matched by: * Literal * Optional spaces followed by a forward slash

    The | in the middle is used to denote an alternative condition (i.e. OR).

    Edit

    Instead of you can also write that you had before.

    Edit 2

    Multiple occurrences can be matched by just adding + behind each pattern:

    preg_replace('#^+|+$#i', "\n", $str);
    

    0 讨论(0)
提交回复
热议问题