| 1260 | // Respectfully strip unnecessary newlines |
| 1261 | function strip_newlines($text) { |
| 1262 | $textarr = preg_split("/(<[^>]+>)/Us", $text, -1, PREG_SPLIT_DELIM_CAPTURE); |
| 1263 | $stop = count($textarr); $skip = false; $output = ''; // loop stuff |
| 1264 | for ($ci = 0; $ci < $stop; $ci++) { |
| 1265 | $curl = $textarr[$ci]; |
| 1266 | if (! $skip && isset($curl{0}) && '<' != $curl{0}) { // If it's not a tag |
| 1267 | $curl = preg_replace('/[\n\r]+/', ' ', $curl); |
| 1268 | } elseif (strpos($curl, '<code') !== false || strpos($curl, '<pre') !== false || strpos($curl, '<kbd') !== false || strpos($curl, '<style') !== false || strpos($curl, '<script') !== false) { |
| 1269 | $next = false; |
| 1270 | } else { |
| 1271 | $next = true; |
| 1272 | } |
| 1273 | $output .= $curl; |
| 1274 | } |
| 1275 | return $output; |
| 1276 | } |
| 1277 | |