How to insert a string inside another string?

后端 未结 3 839
被撕碎了的回忆
被撕碎了的回忆 2020-12-29 22:18

Just looked at function

str_pad($input, $pad_length, $pad_str, [STR_PAD_RIGHT, STR_PAD_LEFT, or STR_PAD_BOTH])

which helps to pad some str

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-29 22:39

    Bah, I misread the question. You want a single insert, not insert every X characters. Sorry.

    I'll leave it here so it's not wasted.

    You can use regular expressions and some calculation to get your desired result (you probably could make it with pure regexp, but that would be more complex and less readable)

    vinko@mithril:~$ more re.php
    
    vinko@mithril:~$ php re.php
    123@123@123
    123@12
    123$12
    

提交回复
热议问题