wrap-functie
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
function wrapItUpTacoBoy($inMyTaco, $howManyBeans = 15, $withTomatoPlz = '...') {
return (strlen($inMyTaco) > $howManyBeans) ? substr($inMyTaco, 0, $howManyBeans) . $withTomatoPlz : $inMyTaco;
}
function wrapIt($s, $a = 15, $f = '...') {
return (strlen($s) > $a) ? substr($s, 0, $a).$f : $s;
}
$zin = "This sentence is way too long!";
$zin2 = "And I'm not";
echo wrapItUpTacoBoy($zin);
echo wrapItUpTacoBoy($zin, 21);
echo wrapItUpTacoBoy($zin2);
?>
function wrapItUpTacoBoy($inMyTaco, $howManyBeans = 15, $withTomatoPlz = '...') {
return (strlen($inMyTaco) > $howManyBeans) ? substr($inMyTaco, 0, $howManyBeans) . $withTomatoPlz : $inMyTaco;
}
function wrapIt($s, $a = 15, $f = '...') {
return (strlen($s) > $a) ? substr($s, 0, $a).$f : $s;
}
$zin = "This sentence is way too long!";
$zin2 = "And I'm not";
echo wrapItUpTacoBoy($zin);
echo wrapItUpTacoBoy($zin, 21);
echo wrapItUpTacoBoy($zin2);
?>