Friday, 19 September 2014

PHP characters limit 10 for display

<?php
echo substr(strip_tags("welcome to this new style editor for checking php code at online"), 2, 10);
?>


substr: Return "world" from the string: 
syntax: substr(string,start,length).

If the start parameter is a negative number and length is less than or equal to start, length becomes 0.

Parameter Description
   string        Required. Specifies the string to return a part of
   start Required. Specifies where to start in the string
  • A positive number - Start at a specified position in the string
  • A negative number - Start at a specified position from the end of the string
  • 0 - Start at the first character in string
   length Optional. Specifies the length of the returned string. Default is to the end of the string.
  • A positive number - The length to be returned from the start parameter
  • Negative number - The length to be returned from the end of the string

0 comments:

Post a Comment