| | 1264 | /** |
| | 1265 | * strip_html_newlines() - Strip unnecessary newlines from HTML code |
| | 1266 | * |
| | 1267 | * This function removes any unnecessary newlines in HTML |
| | 1268 | * code. Useful for cleaning up RSS feeds before import. |
| | 1269 | * |
| | 1270 | * @since 2.5 |
| | 1271 | * |
| | 1272 | * @param string $text The HTML code to strip newlines from |
| | 1273 | * @return string $text with newlines stripped |
| | 1274 | */ |
| | 1275 | function strip_html_newlines($text) { |
| | 1276 | $textarr = preg_split("/(<[^>]+>)/Us", $text, -1, PREG_SPLIT_DELIM_CAPTURE); |
| | 1277 | for ($ci = 0; $ci < count($textarr); $ci++) { |
| | 1278 | $curl = $textarr[$ci]; |
| | 1279 | if (isset($curl{0}) && '<' != $curl{0}) { // If it's not a tag |
| | 1280 | $curl = preg_replace('/[\n\r]+/', ' ', $curl); |
| | 1281 | } |
| | 1282 | $output .= $curl; |
| | 1283 | } |
| | 1284 | return $output; |
| | 1285 | } |
| | 1286 | |