Limiting a text characters is displaying a limit number a characters from a text ( not to show all the text )
The function we will use for that is substr and the syntax is:
substr($message, start, length) ;
$message : we put the text into that variable.
Start : Where you want to start dislaying text from ( put the number of character starting by 0 ).
Length : Define how many character you want to display.
( be sure that the Length is less than the text character’s number !)
Example1
< ?php
$length = 12 ;
$text = "Learn PHP With MistreX" ;
$display = substr($text, 0, $length) ;
echo $display;
echo "..." ;
?>
The function we will use for that is substr and the syntax is:
substr($message, start, length) ;
$message : we put the text into that variable.
Start : Where you want to start dislaying text from ( put the number of character starting by 0 ).
Length : Define how many character you want to display.
( be sure that the Length is less than the text character’s number !)
Example1
< ?php
$length = 12 ;
$text = "Learn PHP With MistreX" ;
$display = substr($text, 0, $length) ;
echo $display;
echo "..." ;
?>