-1

PHP を使用して、指定されたコンテンツから改行と改行を削除する必要があります。方法を教えてください。

  <p>\r\n    \r\n        \r\n            \r\n        \r\n        \r\n            \r\n            \r\n        \r\n        \r\n            \r\n            \r\n        \r\n        \r\n            \r\n            \r\n        \r\n        \r\n            \r\n            \r\n        \r\n        \r\n            \r\n            \r\n        \r\n        \r\n            \r\n            \r\n        \r\n    \r\n</p>
<table width="\&quot;100%\&quot;" class="\&quot;table-view\&quot;" cellpadding="\&quot;0\&quot;" cellspacing="\&quot;0\&quot;">
    <tbody>
        <tr>
            <th colspan="\&quot;2\&quot;" align="\&quot;left\&quot;">Specifications</th>
        </tr>
        <tr>
            <td valign="\&quot;top\&quot;"><strong>Frequency bands</strong></td>
            <td>\r\n
            <ul>\r\n
                <li>380 - 400 MHz</li>
                \r\n
                <li>410 - 430 MHz</li>
                \r\n
                <li>806 - 825, 851 - 870 MHz*</li>
                \r\n            </ul>
                \r\n</td>
            </tr>
            <tr>
                <td valign="\&quot;top\&quot;"><strong>Power class</strong></td>
                <td>\r\n
                <ul>\r\n
                    <li>EN 300392-2 compliant, power class 4</li>
                    \r\n
                    <li>Receiver class A</li>
                    \r\n
                    <li>RF power control, 4 steps of 5dB</li>
                    \r\n            </ul>
                    \r\n</td>
                </tr>
                <tr>
                    <td valign="\&quot;top\&quot;"><strong>Size</strong></td>
                    <td>\r\n
                    <ul>\r\n
                        <li>Weight: 292 g</li>
                        \r\n
                        <li>Dimensions: 157 x 57 x 35 mm</li>
                        \r\n            </ul>
                        \r\n</td>
                    </tr>
                    <tr>
                        <td valign="\&quot;top\&quot;"><strong>Durability</strong></td>
                        <td>\r\n
                        <ul>\r\n
                            <li>High-resolution, active TFT colour display</li>
                            \r\n
                            <li>Up to 65,536 colours with 130x130 pixels</li>
                            \r\n
                            <li>Display texts in more than 20 languages</li>
                            \r\n
                            <li>Support for Latin, Arabic, Greek, Chinese and Korean</li>
                            \r\n            </ul>
                            \r\n</td>
                        </tr>
                        <tr>
                            <td valign="\&quot;top\&quot;"><strong>Keypad / Controls</strong></td>
                            <td>\r\n
                            <ul>\r\n
                                <li>2-sided user interface</li>
                                \r\n
                                <li>Alphanumeric keypad</li>
                                \r\n
                                <li>4 navigation keys, 3 selection keys</li>
                                \r\n
                                <li>HI/LO key for loudspeaker control</li>
                                \r\n
                                <li>Power-on key, volume keys, red function key, duty key, fast menu key, group selector, back key</li>
                                \r\n            </ul>
                                \r\n</td>
                            </tr>
                            <tr>
                                <td valign="\&quot;top\&quot;"><strong>GPS receiver</strong></td>
                                <td>\r\n
                                <ul>\r\n
                                    <li>Sensitivity &ndash;152 dBm</li>
                                    \r\n
                                    <li>Cold start accuracy (open sky)*<br />
                                    \r\n                5 metres (50% confidence level)<br />
                                    \r\n                10 meters (95% confidence level)<br />
                                    \r\n                * measured at &ndash;130 dBm<br />
                                    \r\n                HI/LO key for loudspeaker control</li>
                                    \r\n
                                    <li>GPS activity indicator</li>
                                    \r\n            </ul>
                                    \r\n</td>
                                </tr>
                            </tbody>
                        </table>
4

4 に答える 4

1

先頭/末尾の文字セットをクリアするには、php のtrim()関数を使用します。

" " (ASCII 32 (0x20)), an ordinary space.
"\t" (ASCII 9 (0x09)), a tab.
"\n" (ASCII 10 (0x0A)), a new line (line feed).
"\r" (ASCII 13 (0x0D)), a carriage return.
"\0" (ASCII 0 (0x00)), the NUL-byte.
"\x0B" (ASCII 11 (0x0B)), a vertical tab.
于 2013-10-29T10:49:06.960 に答える
0

たくさんあるみたい\r\n.

したがって、単純なものstr_replaceで十分です。

<?php
$string=str_replace("\r\n","",$string);
于 2013-10-29T10:50:30.480 に答える
0

str_replace 関数を使用しますか?

PHP よくある質問

于 2013-10-29T10:51:33.843 に答える