-
Notifications
You must be signed in to change notification settings - Fork 1
/
lib.php
23 lines (18 loc) · 891 Bytes
/
lib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
// common functions used by several scripts
// http://es1.php.net/manual/en/function.strip-tags.php#110280
// better than strip_tags() because "<p>Mål</p>Dette er" --> "Mål Dette er"
// would be "MålDette er" with strip_tags
function rip_tags($string) {
// ----- remove HTML TAGs -----
$string = preg_replace ('/<[^>]*>/', ' ', $string);
// ----- remove control characters -----
$string = str_replace("\r", '', $string); // --- replace with empty space
$string = str_replace("\n", ' ', $string); // --- replace with space
$string = str_replace("\t", ' ', $string); // --- replace with space
$string = str_replace(chr(0xC2).chr(0xA0), ' ', $string); // --- converts no-break-space to normal space
// ----- remove multiple spaces -----
$string = trim(preg_replace('/ {2,}/', ' ', $string));
return $string;
}
?>