str_replace或字符串提取删除回车


str_replace or string extraction remove carriage return

下面的代码返回HTML页面的脚本标记$fullink的内容。我的问题是,所有的东西都只在一条线上,回车取消了出现。我该怎么修?

$page = file_get_html($fullink);
        function extractString($string, $start, $end) {
            $string = " ".$string;
            $ini = strpos($string, $start);
            if ($ini == 0) return "";
            $ini += strlen($start);
            $len = strpos($string, $end, $ini) - $ini;
            return substr($string, $ini, $len);
        }
        $string = file_get_html($fullink);
        $brut = extractString($string, 'resultslines', '//--');
        $brut2 = str_replace(',',',<br/>',$brut);
        echo '<SCRIPT TYPE="text/javascript" SRC="raceresults.js"></SCRIPT>';
        echo '<SCRIPT TYPE="text/javascript"><!-- 'n resultslines' . $brut2 .'//--><br/></SCRIPT>';

电流输出:

<!--resultslines=["dir=2013_EMF_Bogny_Sur_Meuse", "longname=2013 EMF FrenchCup Rd1 : Bogny Sur Meuse", "firstlap=20", "normallap=32", "holeshotindex=1", "time=61440", "laps=1", "starttime=1752", "date=1409502349", "players:", "slot=0", "uid=6864", "number=191", "bike=rm125", "name=Eddie Ozel", "times:", "0 0 2543", "0 1 3411", "0 2 3790", "0 3 4483", "0 4 5231", "0 5 5838", "0 6 6144", "0 7 6779", "0 8 7212", "0 9 7582", "0 10 8282", "0 11 8857", "0 12 9531", "0 13 10047", "0 14 12720", "0 15 12916", "0 16 13252", "0 17 13949", "0 18 14384", "0 19 15023", "0 20 15565", "0 21 16051", "0 22 16560", "0 23 17079", "0 24 17369", "0 25 17734", "0 26 18180", "0 27 18452", "0 28 18589", "0 29 18932", "0 30 19166", "0 31 20259", "0 32 20585", "0 33 20941", "0 34 21275", "0 35 22589", "0 36 23247", "0 37 23799", "0 38 24048", "0 39 25224", "0 40 25610", "0 41 26007", "0 42 26726", "0 43 27233", "0 44 27774", "0 45 28220", "0 46 28816", "0 47 29064", "0 48 29393", "0 49 30133", "0 50 30465", "0 51 31171", "0 52 31738", "0 53 32224", "0 54 32698", "0 55 33150", "0 56 33438", "0 57 33781", "0 58 34216", "0 59 34515", "0 60 34670", "0 61 34990", "0 62 35231", "0 63 35497", "0 64 35780", "0 65 36117", "0 66 36467", "0 67 37106", "0 68 38137", "0 69 38690", "0 70 38948", "0 71 39566", "0 72 39916", "0 73 40497", "0 74 41169", "0 75 41731", "0 76 42248", "0 77 42724", "0 78 43333", "0 79 43566", "0 80 43907", "0 81 44714", "0 82 45824", "0 83 46484", "0 84 47028", "0 85 47514", "0 86 47991", "0 87 48442", "0 88 48726", "0 89 49066", "0 90 49493", "0 91 49786", "0 92 49935", "0 93 50219", "0 94 50454", "0 95 50781", "0 96 51105", "0 97 51441", "0 98 51785", "0 99 52567", "0 100 53108", "0 101 53653", "0 102 53898", "0 103 58629", "0 104 58967", "0 105 59371", "0 106 60034", "0 107 60549", "0 108 61101", "0 109 61610", "0 110 62274", "0 111 62454", "0 112 62782", "0 113 63642", "0 114 64049", "0 115 64680", "0 116 68983", "0 117 69522", "0 118 70025", "0 119 70490", "0 120 70780", "0 121 71087", "0 122 71512", "0 123 71794", "0 124 71927", "0 125 73390", "0 126 73667", "0 127 74064", "0 128 74374", "0 129 74715", "0 130 75056", "0 131 75728", "0 132 76972", "0 133 77537", "0 134 77748", "0 135 78481", "0 136 79002", "0 137 79316", "0 138 80092", "0 139 80622", "0 140 81238", "0 141 82723", "0 142 83446", "0 143 83624", "0 144 83924", "0 145 84752", "0 146 85050", "0 147 85712", "", ] print_race_analysis(resultslines)  //--><br/>

所需输出:

<!--
resultslines=["dir=2013_EMF_Bogny_Sur_Meuse",
"longname=2013 EMF FrenchCup Rd1 : Bogny Sur Meuse",
"firstlap=20",
"normallap=32",
"holeshotindex=1",
"time=61440",
(...)
"0 146 85050",
"0 147 85712",
"",
]
print_race_analysis(resultslines)
//-->

好的,这很棘手。事实上,正如您所看到的,我使用了echo"来显示我的代码,''r''n或者只是用引号打印。要插入回车,我必须使用双引号-->echo",而且它很有效。