删除换行符和回车符的函数不起作用


Function for removal of newline and carriage return is not working

我已经尝试了许多可能的方法,但仍然不起作用。

遵循从数据中删除'r'n'r'n的所有可能性。它们都不工作

$data = strtr($data, array(
              "'r'n" => "",
              "'r" => "",
              "'n" => "",
              "'t" => " "));
$data = str_replace(array("'r","'n","'r'n"), '', $data);
$data = preg_replace("'r'n", '', $data);
$data = preg_replace(array("'r","'n","'r'n"), '', $data);
$data = preg_replace("~['r'n]+~", '', $data);
$data = trim(preg_replace(array("'r","'n"), '', $data));
$data = trim(preg_replace('/'s's+/', ' ', $data));

var_dump($data)是包含一些html装饰标签的数据

    array(3) { ["flag"]=> string(7) "success" ["data"]=> array(3) { ["data"]=> array(3) { [108955]=> array(15) { ["pkgname"]=> string(0) "" ["name"]=> string(28) "SI - Mundome - Win iPhone 6s" ["preview_url"]=> string(32) "http://m.sk.mevida.me/wap/9766/?" ["type"]=> string(5) "other" ["title"]=> string(0) "" ["description"]=> NULL ["offer_description"]=> string(972) "
æ— æ ‡é¢˜æ–‡æ¡£
All banners , Text, bridge pages must be approved in advance. No words like "free" or "you have won".
User Conversion Flow: MO Flow with Click2SMS:
1.User clicks on the banner
2.User fill into his SMS application
3.User clicks on the confirmation button.
4.User's service request is received.
GEO: Slovenia
Device:All Device
Carriers:All carrier
Caps:NO
Push Notification traffic allowed:Yes
Incentivized Traffic allowed:NO
Email Traffic allowed:Yes
Adult traffic allowed:NO
Search traffic allowed:Yes
SMS Traffic allowed:NO
Wifi traffic allowed:Yes
" ["category"]=> array(1) { [0]=> string(24) "Sweepstakes Subscription" } ["tracklink"]=> string(63) "http://global.ymtracking.com/trace?offer_id=108955&aff_id=22097" ["countries"]=> array(1) { [0]=> string(2) "SI" } ["payout"]=> string(5) "6.500" ["platform"]=> array(38) { [0]=> string(7) "Desktop" [1]=> string(3) "iOS" [2]=> string(7) "Android" [3]=> string(17) "BlackBerry Tablet" [4]=> string(5) "MeeGo" [5]=> string(10) "BlackBerry" [6]=> string(7) "Unknown" [7]=> string(5) "Linux" [8]=> string(4) "Bada" [9]=> string(13) "Windows Phone" [10]=> string(7) "Symbian" [11]=> string(14) "Windows Mobile" [12]=> string(16) "PlayStation Vita" [13]=> string(12) "Nintendo Wii" [14]=> string(5) "Nokia" [15]=> string(10) "Windows RT" [16]=> string(9) "Series 40" [17]=> string(11) "Playstation" [18]=> string(3) "SGP" [19]=> string(11) "MTK/Nucleus" [20]=> string(5) "Maemo" [21]=> string(3) "PSP" [22]=> string(4) "Java" [23]=> string(9) "Windows 8" [24]=> string(4) "Palm" [25]=> string(6) "Danger" [26]=> string(5) "webOS" [27]=> string(12) "Nintendo DSi" [28]=> string(7) "Windows" [29]=> string(12) "Nintendo 3DS" [30]=> string(4) "Brew" [31]=> string(3) "MMP" [32]=> string(4) "MIDP" [33]=> string(6) "Aliyun" [34]=> string(12) "Windowsphone" [35]=> string(7) "Samsung" [36]=> string(7) "Brew MP" [37]=> string(7) "Firefox" } ["traffic"]=> array(4) { [0]=> string(21) "Email Traffic allowed" [1]=> string(22) "Search traffic allowed" [2]=> string(20) "Wifi traffic allowed" [3]=> string(33) "Push Notification traffic allowed" } ["creative_link"]=> array(0) { } ["remaining_daily_cap"]=> int(-1) } [108956]=> array(15) { ["pkgname"]=> string(21) "il.co.dominos.android" ["name"]=> string(60) "App Download - Domino''s Pizza - Android(IL) - Non incentive" ["preview_url"]=> string(67) "https://play.google.com/store/apps/details?id=il.co.dominos.android" ["type"]=> string(7) "android" ["title"]=> string(23) "×“×•×ž×™× ×•×¡ פיצה" ["description"]=> string(2274) "×× ×—× ×• ×ž×–×ž×™× ×™× ×ותך להוריד ×‘×—×™× × ×•×œ×™×”× ×•×ª עוד ×”×™×•× ×ž×פליקציית ×”×–×ž× ×•×ª הפיצה המהירה, ×”×ž×”× ×” והחכמה ביותר בעול×!××– מה ×”×›× ×• ×œ×›× ×‘×פליקציה הלוהטת ×©×œ× ×• –· ONE CLICK PIZZA - ×“×•×ž×™× ×•'ס פיצה משיקה שירות ×˜×›× ×•×œ×•×’×™ ×—×“×©× ×™ × ×•×¡×£ של בדרך ×œ×”×–×ž× ×ª הפיצה המהירה בעול×! ×ž×”×™×•× × ×•×›×œ בלחיצת כפתור ×חת להטעין ×”×–×ž× ×ª פיצה בפחות מחמש ×©× ×™×•×ª ותוך פחות מחצי שעה הפיצה כבר תדפוק ××¦×œ×›× ×‘×“×œ×ª חמה וטעימה. החל מהיו×, כל לקוח ×“×•×ž×™× ×•'ס, שהזמין בעבר מהרשת, יוכל בלחיצת כפתור ×חת (מ×פליקציית המובייל, ×ו מה×תר של החברה) להטעין ×‘×©× ×™×•×ª בודדות ×ת ×”×”×–×ž× ×” הקבועה שלו החל מהכתובת למשלוח ועד ×מצעי התשלו×. כפתור ×”- ONE CLICK PIZZA מציע ×’× ×פשרויות בחירה מהירות ב×מצעות סליידר בין ×”×ופציות השכיחות ביותר בשדות ×”×©×•× ×™×, כך ×‘×©× ×™×™×” × ×™×ª×Ÿ לבחור בין שתי כתובות מגורי×, ×ו כמובן בין שתי פיצות מעודפות. § הרכבת הפיצה ×”×הובה עליך- בעזרת ×”- Pizza builder, ×שף הרכבת הפיצה ×”×ž×ª×§×“× ×‘×™×§×•×, ×”×›×™ קל להרכיב ×ת הפיצה המושלמת בשבילך: לבחור סוג בצק, לחלק ×ת התוספות לחצ××™× ×ו ×¨×‘×¢×™× (×פשר ×œ×©×™× ×ª×•×¡×¤×ª ×©×•× ×” על כל רבע וזה × ×—×©×‘ לתוספת ×חת!) ועוד ×ž×œ× ×פשרויות ×חרות.§ ×יפה הפיצה שלי- רוצה לדעת מה קורה ×¢× ×”×¤×™×¦×” שלך בכל רגע? ×ין בעיה! Domino's Tracker ×”×•× ×¤×™×ª×•×— בלעדי וסופר ×ž×ª×§×“× ×שר מ×פשר ×œ×›× ×œ×¢×§×•×‘ בזמן ×מת ×חרי ×”×”×–×ž× ×” שלך בכל שלב, מרגע שהתקבלה ×‘×¡× ×™×£ ועד שהשליח ×צלך בדלת.בת×בון!×× ×™×© לך ש×לות ×ו הערות ×‘× ×•×’×¢ ל×פליקציה, ×× ×—× ×• תמיד ×©×ž×—×™× ×œ×¢×ž×•×“ לרשותך ×‘×›×ª×•×‘×ª× ×• android@dominos.co.il" ["offer_description"]=> string(1163) "
Restrictions
Own Creative, Video Creatives, APK, Redirect traffic cannot be used.
No invalid or duplicate leads
All banners and bridge pages should be approved in advance.
User Conversion Flow:
1. User is directly redirected on Google Play to download the application
2. User has to open the application
GEO: Israel
Device: Android
Carrier: All
Cap: 400 leads per day
Push Notification traffic allowed: Yes
Incentivized traffic allowed: No
Search traffic allowed: Yes
Adult traffic allowed: No
Email traffic allowed: Yes
SMS traffic allowed: Yes
Wifi traffic allowed: Yes
Facebook traffic allowed: Yes
In App Traffic allowed(APP): Yes


" ["category"]=> array(1) { [0]=> string(20) "App Download-Android" } ["tracklink"]=> string(63) "http://global.ymtracking.com/trace?offer_id=108956&aff_id=22097" ["countries"]=> array(1) { [0]=> string(2) "IL" } ["payout"]=> string(5) "0.680" ["platform"]=> array(1) { [0]=> string(7) "Android" } ["traffic"]=> array(7) { [0]=> string(21) "Email Traffic allowed" [1]=> string(22) "Search traffic allowed" [2]=> string(19) "SMS Traffic allowed" [3]=> string(20) "Wifi traffic allowed" [4]=> string(33) "Push Notification traffic allowed" [5]=> string(32) "In - App Display traffic allowed" [6]=> string(24) "Facebook traffic allowed" } ["creative_link"]=> array(1) { [0]=> string(81) "http://uploads.yeahmobi.com/offer_file/thumb_e90b2203193e7dcf48ff234d8c50e585.zip" } ["remaining_daily_cap"]=> int(392) } [108957]=> array(15) { ["pkgname"]=> string(0) "" ["name"]=> string(30) "MY - Snacpchat - Celcom & Digi" ["preview_url"]=> string(73) "http://adsplatform.com/ads/?adsid=938e08930da59143d3296955fde269c4&e=1912" ["type"]=> string(5) "other" ["title"]=> string(0) "" ["description"]=> NULL ["offer_description"]=> string(661) "
æ— æ ‡é¢˜æ–‡æ¡£
All banners and bridge pages should be approved in advance. No prelanders!!!
One Click Flow: Single-Optin
GEO: MY
Device: All
Carrier:Celcom & Digi
Push Notification traffic allowed: Yes
Incentivized traffic allowed: No
Adult traffic allowed: Yes
Wifi traffic allowed: Yes
Search traffic allowed: Yes
display traffic allowed: Yes
" ["category"]=> array(1) { [0]=> string(26) "Entertainment Subscription" } ["tracklink"]=> string(63) "http://global.ymtracking.com/trace?offer_id=108957&aff_id=22097" ["countries"]=> array(1) { [0]=> string(2) "MY" } ["payout"]=> string(5) "2.500" ["platform"]=> array(1) { [0]=> string(7) "Desktop" } ["traffic"]=> array(5) { [0]=> string(21) "Adult traffic allowed" [1]=> string(22) "Search traffic allowed" [2]=> string(20) "Wifi traffic allowed" [3]=> string(33) "Push Notification traffic allowed" [4]=> string(23) "Display traffic allowed" } ["creative_link"]=> array(1) { [0]=> string(81) "http://uploads.yeahmobi.com/offer_file/thumb_21ffc6a2782ffe160a0a183eb25c6e49.ZIP" } ["remaining_daily_cap"]=> int(-1) } } ["totalrecord"]=> int(4028) ["totalpage"]=> int(1343) } ["msg"]=> string(8) "success." } 

'n'r是转义字符,只有在双引号字符串中使用时才会转义。''r'n'"'r'n"之间存在较大差异

''r'n'将产生一个包含一个斜杠、一个'r'、另一个斜杠和一个'n'的四个字符的字符串,而"'r'n"将包含两个字符,它们是新的换行符和回车符。

    //$text in string format
    $text = str_replace("'r'n",'', $text);

使用preg_replace'R特殊字符,它将替换所有出现的新行,并且它是跨平台的。

preg_replace( '/'R+/', '', $string );