özet gösterme kodu

 
1
2
3
4
5
6
7
8
9
10
11
<!--?
 
$position=14; // Define how many character you want to display.
 
$message="You are now joining over 2000 current"; 
$post = substr($message, 0, $position); 
 
echo $post;
echo "..."; 
 
?-->

This result shows 14 characters from your message

“You are now jo…”

This is not good. We want to display “You are now joining…”
Let’s solve this problem in example 2.

Özeti Kelimeyi tamamladıktan sonra kemek için kod

 
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<!--?
$position=14; // Define how many characters you want to display.
 
$message="You are now joining over 2000 current"; 
$post = substr($message,$position,1); // Find what is the last character displaying. We find it by getting only last one character from your display message.
 
if($post !=" "){ // In this step, if last character is not " "(space) do this step .
 
// Find until we found that last character is " "(space) 
// by $position+1 (14+1=15, 15+1=16 until we found " "(space) that mean character 20) 
while($post !=" "){
$i=1;
$position=$position+$i;
 
$message="You are now joining over 2000 current"; 
$post = substr($message,$position,1); 
}
 
}
 
$post = substr($message,0,$position); // Display your message
echo $post;
echo "...";
?-->
Related Posts Plugin for WordPress, Blogger...
PHP kategorisine gönderildi

Bir Cevap Yazın

Son Yazılar

doraglass