PHP “backspace” character during output possible?

后端 未结 8 1106
囚心锁ツ
囚心锁ツ 2021-02-13 04:30

I have a feeling the answer is \"it\'s not possible,\" but thought I\'d ask to satisfy my curiosity.

I have some code that\'s echoed where the \\n is unavoidable:

<
8条回答
  •  情歌与酒
    2021-02-13 04:53

    What about just replacing the "\n" by a white space (or just nothing, if you already have one space in your incoming string) ?

    Like this, for instance :

    $str = "Hello\nWorld!";
    var_dump($str);
    
    $str = str_replace("\n", ' ', $str);
    var_dump($str);
    

    The first output gives :

    string 'Hello
    World!' (length=12)
    

    And the second one :

    string 'HelloWorld!' (length=11)
    

    Is that not enough ?
    (Or maybe I don't understand the question well)

提交回复
热议问题