php inkorten
ik heb een vraag ik he een beschrijfing alleen ik wil dat hij als hij te lang word het outomatisch inkort en eindigt mer ... wie weet hoe dat script moet maken.
kan je je vraag duidelijk stellen + meer informatie geven over wat je vraag is, want ik snap echt niet wat je vraag is..
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
<?php
function truncate_end ($str, $limit = 25, $ending = '...') {
if (strlen ($str) > $limit) {
$text = strip_tags ($str);
$text = substr ($text, 0, $limit);
$text = substr ($text, 0, - (strlen (strrchr ($text, ' '))));
$text = $text . $ending;
}
return $text;
}
echo truncate_end ('the quick brown fox jumped over the lazy dog');
?>
function truncate_end ($str, $limit = 25, $ending = '...') {
if (strlen ($str) > $limit) {
$text = strip_tags ($str);
$text = substr ($text, 0, $limit);
$text = substr ($text, 0, - (strlen (strrchr ($text, ' '))));
$text = $text . $ending;
}
return $text;
}
echo truncate_end ('the quick brown fox jumped over the lazy dog');
?>
net als hiet bij phphulp als een titel te lang is kort hij hem in en zet hij ... erachter kijk links in het menu
Zie mijn vorige post ;-)
Fatal error: Cannot redeclare truncate_end() (previously declared in /home/a1355588/public_html/browse.php:214) in /home/a1355588/public_html/browse.php on line 214
De functie truncate_end wordt twee keer gedeclareerd. Laat eens een klein stukje relevante code zien?
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?PHP
// see if you are an admin. if so, add a [EDIT] link to the line
$admin_edit = "";
if (IsAdmin() == true) {
$admin_edit = "<br /><br />";
if ($stock_enabled == 1) { $admin_edit .= $txt['productadmin12'].": ".$row[5]."<br />"; }
$admin_edit .= "<a href=\"?page=productadmin&action=edit_product&pcat=".$cat."&prodid=".$row[0]."\">".$txt['browse7']."</a>";
$admin_edit .= " | <a href=\"?page=productadmin&action=delete_product&pcat=".$cat."&prodid=".$row[0]."\">".$txt['browse8']."</a>";
$admin_edit .= " | <a href=\"?page=productadmin&action=picture_upload_form&picid=".$picture."\">".$txt['browse10']."</a>";
}
// make up the description to print according to the pricelist_format and max_description
if ($pricelist_format == 0) { $print_description = $row[1]; }
if ($pricelist_format == 1) { $print_description = $row[3]; }
if ($pricelist_format == 2) { $print_description = "".$row[1]."-<b>-</b> - ".$row[3].""; }
if ($max_description != 0) {
}
$print_description = $print_description; //remove html because of danger of broken tags
$str = $print_description; //remove html because of danger of broken tags
echo "<tr".$kleur.">";
[/code][code]
function truncate_end ($str, $limit = 25, $ending = '...') {
if (strlen ($str) > $limit) {
$text = strip_tags ($str);
$text = substr ($text, 0, $limit);
$text = substr ($text, 0, - (strlen (strrchr ($text, ' '))));
$text = $text . $ending;
}
return $text;
}
echo truncate_end ('the quick brown fox jumped over the lazy dog');
[/code][code]
// see what the stock is
if ($stock_enabled == 0) {
if ($row[5] == 1) { $stockpic = "<img class=\"imgleft\" src=\"".$gfx_dir."/bullit_green.gif\" alt=\"".$txt['db_stock1']."\" /> "; } // in stock
if ($row[5] == 0) { $stockpic = "<img class=\"imgleft\" src=\"".$gfx_dir."/bullit_red.gif\" alt=\"".$txt['db_stock2']."\" /> "; } // out of stock
if ($row[5] == 2) { $stockpic = "<img class=\"imgleft\" src=\"".$gfx_dir."/bullit_orange.gif\" alt=\"".$txt['db_stock3']."\" /> "; } // in backorder
}
?>
// see if you are an admin. if so, add a [EDIT] link to the line
$admin_edit = "";
if (IsAdmin() == true) {
$admin_edit = "<br /><br />";
if ($stock_enabled == 1) { $admin_edit .= $txt['productadmin12'].": ".$row[5]."<br />"; }
$admin_edit .= "<a href=\"?page=productadmin&action=edit_product&pcat=".$cat."&prodid=".$row[0]."\">".$txt['browse7']."</a>";
$admin_edit .= " | <a href=\"?page=productadmin&action=delete_product&pcat=".$cat."&prodid=".$row[0]."\">".$txt['browse8']."</a>";
$admin_edit .= " | <a href=\"?page=productadmin&action=picture_upload_form&picid=".$picture."\">".$txt['browse10']."</a>";
}
// make up the description to print according to the pricelist_format and max_description
if ($pricelist_format == 0) { $print_description = $row[1]; }
if ($pricelist_format == 1) { $print_description = $row[3]; }
if ($pricelist_format == 2) { $print_description = "".$row[1]."-<b>-</b> - ".$row[3].""; }
if ($max_description != 0) {
}
$print_description = $print_description; //remove html because of danger of broken tags
$str = $print_description; //remove html because of danger of broken tags
echo "<tr".$kleur.">";
[/code][code]
function truncate_end ($str, $limit = 25, $ending = '...') {
if (strlen ($str) > $limit) {
$text = strip_tags ($str);
$text = substr ($text, 0, $limit);
$text = substr ($text, 0, - (strlen (strrchr ($text, ' '))));
$text = $text . $ending;
}
return $text;
}
echo truncate_end ('the quick brown fox jumped over the lazy dog');
[/code][code]
// see what the stock is
if ($stock_enabled == 0) {
if ($row[5] == 1) { $stockpic = "<img class=\"imgleft\" src=\"".$gfx_dir."/bullit_green.gif\" alt=\"".$txt['db_stock1']."\" /> "; } // in stock
if ($row[5] == 0) { $stockpic = "<img class=\"imgleft\" src=\"".$gfx_dir."/bullit_red.gif\" alt=\"".$txt['db_stock2']."\" /> "; } // out of stock
if ($row[5] == 2) { $stockpic = "<img class=\"imgleft\" src=\"".$gfx_dir."/bullit_orange.gif\" alt=\"".$txt['db_stock3']."\" /> "; } // in backorder
}
?>
Gewijzigd op 01/01/1970 01:00:00 door rick geenidee
ik denk dat je die code waarin die functie staat dubbel includeerd. Net zoals een huisnummer uniek dient te zijn, moet dit ook met functies die je defineert.
Om dubbel includen en requiren te voorkomen, kun je gebruik maken van include_once en require_once.