Jump to content
  • Hello visitors, welcome to the Hacker World Forum!

    Red Team 1949  (formerly CHT Attack and Defense Team) In this rapidly changing Internet era, we maintain our original intention and create the best community to jointly exchange network technologies. You can obtain hacker attack and defense skills and knowledge in the forum, or you can join our Telegram communication group to discuss and communicate in real time. All kinds of advertisements are prohibited in the forum. Please register as a registered user to check our usage and privacy policy. Thank you for your cooperation.

    TheHackerWorld Official

PHP中nl2br函数,那有没有它的反函数br2nl?

 Share


Recommended Posts

文章来源:https://www.yerenwz.com/6565.html

是的,感觉正常人的第一反应是既然有nl2br函数,那必然有反函数br2nl,然后实际上野人告诉你是没有的,哈哈哈。

所以就得自己实现,实现的话,老实说还是挺简单,但是再简单,野人还是希望官网能出在个方法,毕竟不是自己额外封装,多香啊,拿来即用,不好吗?学会CV才是编程界“最厉害”的方法。

废话就不给大家多说了,直接上br2nl的代码实例教程吧。

<?php
function br2nl($text)
{
    return preg_replace('/<br\\s*?\/??>/i', chr(13), $text);
}
var_dump(br2nl('1<br />2'));
?>
Link to post
Link to comment
Share on other sites

 Share

discussion group

discussion group

    You don't have permission to chat.
    • Recently Browsing   0 members

      • No registered users viewing this page.
    ×
    ×
    • Create New...