tekst-afkorten-op-woorden
Gesponsorde koppelingen
PHP script bestanden
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?
function ShortTxt($tekst, $num = '')
{
//-- if $num is empty, set $num to 25
if (!$num)
$num = 25;
//-- count words
$words = explode(" ", $tekst);
$total = count($words);
//-- if there are $num or more words
if ($total >= $num)
{
unset($i);
//-- cut on words, not on letters
for ($i = 0; $i <= $num; $i++)
{
if (!$short)
$short = $words[$i];
else
$short = $short . " " . $words[$i];
}
//-- add "..." to it
$short = $short . "...";
}
//-- less then 30 words, show all
else
$short = $tekst;
//-- return the ajusted (or not) text
return $short;
}
?>
function ShortTxt($tekst, $num = '')
{
//-- if $num is empty, set $num to 25
if (!$num)
$num = 25;
//-- count words
$words = explode(" ", $tekst);
$total = count($words);
//-- if there are $num or more words
if ($total >= $num)
{
unset($i);
//-- cut on words, not on letters
for ($i = 0; $i <= $num; $i++)
{
if (!$short)
$short = $words[$i];
else
$short = $short . " " . $words[$i];
}
//-- add "..." to it
$short = $short . "...";
}
//-- less then 30 words, show all
else
$short = $tekst;
//-- return the ajusted (or not) text
return $short;
}
?>