Monday, 29 September 2014

wordwrap in PHP

PHP strtok() function is utilized to split a string into smaller strings(tokens). Syntax: strtok(string,split) string : Required. Specifies the string to split split : Required. Specifies the string characters token delimiters. Example: <?php $str_name = "Good morning. Have a nice day."; $token_name = strtok($str_name," "); while($token_name != false){      echo "$token_name <br />";      $token_name = strtok(" "); } ?> Output will be: Good morning. Have a nice day. *****************************************************************  PHP...

strstr in PHP

PHP strstr() function is utilized to searches its first string argument to see if its second string argument is contained in it. Returns the substring of the first string that starts with the first instance of the second argument, if any is found – otherwise, it returns false.  Syntax: strstr(string,search) string : Required. Specifies the input string. search : Required.Specifies the string to search for. Note : PHP strstr() function is binary-safe. Note : PHP strstr() function is case-sensitive. For case-insensitive search, use PHP...

strspn in PHP

PHP strspn() function is utilized to get the amount of characters that considered in the principle string that holds only characters from character listed in the second string. Syntax: strspn(string,charlist,start,length) string : Required. Defines the input string to search charlist : Required. Defines the characters to search for start : Optional. Defines where in string to start length : Optional. Defines the length of the string (how much of the string to search). Note : This function is binary safe. Example: <?php echo strspn("Good...

strrpos in PHP

PHP strrpos() function searches backward from end of the string, rather than forward from the beginning. The search string must only be one character long and there is no optional position argument. Returns FALSE if match not found. Syntax: strrpos(string,find,start) string : Required. Specifies the string to examined. find : Required. Specifies the string to find start : Optional. Specifies starting position of the first string. Note : This function is case-sensitive. Example: <?php echo strrpos("Good Morning","o"); ?> Output will...

strripos in PHP

 PHP strripos() function is utilized to discover the position of the final occurrence of a case-insensitive string in a string. Returns FALSE if match not found. Syntax: strripos(string,find,start) string : Required. Specifies the string to examined. find : Required. Specifies the string to find start : Optional.Specifies starting position of the first string. Note : This function is case-insensitive. Example: <?php echo strripos("Good Morning","oR"); ?> Output will be:...

strrev in PHP

PHP strrev() function is used to returned the string with characters reversed. Syntax: strrev(string) string : Required. Specifies the input string to reverse. Example: <?php $str_name = "Good Morning"; echo strrev($str_name); ?> Output will be: gninroM do...

strrchr in PHP

PHP strrchr() function is utilized to find the position of the final occurrence of a string inside another string(main string). If char cannot be found, this function returns FALSE. Syntax: strrchr(string,char) string : Required. Specifies the string to search char : Required. Specifies the searched string. Note : This function is binary-safe. Example: <?php echo strrchr("Good Morning world!","Morning"); echo "<br /><strong> Example using ASCII code for search : </strong><br />"; echo strrchr("Good Morning",111); ?> Output...

strpos in PHP

 PHP Strpos() function is utilized to returns the  position of the beginning of the first instance of the string if found and false value otherwise. Syntax: strpos(string,find,start) string : Required. Specifies the string to search find : Required.Specifies the string being searched for. start : Optional. Specifies the position at which the search should begin. Note : This function is case-sensitive. Example: <?php echo stripos("Good Morning","or"); ?> Output will be:...

strpbrk in PHP

PHP strpbrk() function is utilized to search a string for any set of characters. PHP strpbrk() function returns the rest of the string from where it discovered the first event of a specified character, otherwise it returns FALSE. Syntax: strpbrk(string,charlist) string : Required. Specifies the string to search charlist : Required. Specifies the string being searched for. Tip: This function is case-sensitive. Example: <?php echo strpbrk("Good Morning","dr"); ?> Output will be: d Morni...

strncmp in PHP

PHP strncmp() function is utilized to compares two strings. The function returns : 0 – if the two strings are exactly equivalent. <0 – if smaller byte is found in the string1. >0 –if smaller byte is found in the string2. Syntax: strncmp(string1,string2,length) string1 : Required. Specifies the first string. string2 : Required. Specifies the second string. length : Required. Specify the number of characters to use in the comparison. Tip : This function is binary safe and case-sensitive. Example: <?php echo strncmp("Good Morning","Good...

strncasecmp in PHP

 PHP strncasecmp() function is  identical to strcmp() function ,except that lowercase and uppercase Versions of the same letter compare as equal. The function returns : 0 –if the two strings are exactly equivalent <0 – if smaller byte is found in the string1. >0 – if smaller byte is found in the string2. Syntax: strncasecmp(string1,string2,length) string1 : Required.Specifies the first string. string2 : Required. Specifies the second string. length : Required. Specify the number of characters to use in the comparison. Tip:...

strnatcmp in PHP

 PHP strnatcmp() function is utilized to analyze two strings using a "natural" algorithm. The function returns : 0 – if the two strings are exactly equivalent. <0 – if smaller byte is found in the string1. >0 – if smaller byte is found in the string2. Syntax: strnatcmp(string1,string2) string1 : Required. Specifies the first string string2 : Required. Specifies the second string Tip: This function is case-sensitive. Example: <?php echo strnatcmp("4Good Morning","12Good Morning"); echo "<br />"; echo strnatcmp("12Good...

strnatcasecmp in PHP

 PHP strnatcasecmp() function is utilized to analyze two strings using a "natural" algorithm. The function returns : 0 –if the two strings are exactly equivalent. <0 –if smaller byte is found in the string1. >0 –if smaller byte is found in the string2. Syntax: strnatcasecmp(string1,string2) string1 : Required. Specifies the first string string2 : Required. Specifies the second string Tip: This function is case-insensitive. Example: <?php echo strnatcasecmp("4Good Morning","12Good Morning"); echo "<br />"; echo strnatcasecmp("12Good...

strlen in PHP

PHP strlen() function is used to returns the length of a string i.e number of characters in a string. Syntax: strlen(string) string : Required. Specifies the input string Example: <?php echo strlen("Good Morning"); ?> Output will be: ...

stristr in PHP

PHP stristr() function is used  to searches its first string argument to see if its second string argument is contained in it. Returns the substring of the first string that starts with the first instance of the second argument, if any is found – otherwise it returns false. Syntax: stristr(string,search) string : Required. Specifies the input string to search search : Required. Specifies the string to search for. Note : PHP stristr() function is binary-safe and case-insensitive. For case-sensitive search, use PHP strstr() function. Example: <?php echo...

stripos in PHP

PHP stripos() function is utilized to returns the position of the beginning of the first instance of the string if found and otherwise it returns FALSE. Syntax: stripos(string,find,start) string : Required. Specifies the string to search find : Required. Specifies the string being searched for. start : Optional. Specifies the position at which the search should begin. Note : PHP stripos function is case-insensitive. Example: <?php echo stripos("Good Morning","oR"); ?> Output will be:...

stripslashes in PHP

PHP stripslashes() function is utilized to remove backslashes from given data included by the addslashes() function. Syntax: stripslashes(string) string : Required. Specifies the input string. Tip :  This function could be utilized to clean up a string recovered from a database. Example: <?php echo stripslashes("Who\'s Sam\ Bru\ce?"); ?> Output will be: Who's Sam Bruc...

stripcslashes in PHP

PHP stripcslashes() function is utilized to remove backslashes from given data included by the addslashes() function. Syntax: stripcslashes(string) string : Required. Specifies the input string. Tip : This function could be utilized to clean up a string recovered from a database. Note : PHP stripcslashes() skips special character sets like "\n" and "\r", preserving any line breaks, return carriages, etc. Example: <?php echo stripcslashes("Good \Morning, m\y name\ is Sam\."); ?> Output will be: Good Morning, my name is Sa...

strip_tags in PHP

PHP strip_tags() function is utilized to strips out all HTML, PHP and XML tags from given string. It also strip out all HTML comments. Syntax: strip_tags(string,allow) string : Required. Specifies the input string allow : Optional. Specifies the tags which will not be evacuated Note: This function is binary-safe. Example: <?php echo strip_tags("Good <b>Morning</b>"); echo "<br /><strong>Example using allow parameter : </strong><br />"; echo strip_tags("Good <b><i>Morning</i></b>","<b>"); ?> Output...

strcspn in PHP

PHP strcspn() function is utilized to get the amount of characters that happen between the begin of the main string and the first event of any character listed in the second string. Syntax: strcspn(string,char,start,length) string : Required. Defines input string. char : Required. Defines the characters . start : Optional. Defines where in string to start length : Optional. Defines the length of the string (how much of the string to search) Note: This function is binary safe. Example: <?php echo strcspn("Good Morning","r"); ?> The...

strcoll in PHP

PHP strcoll() function is utilized to compare two strings.This function utilizes current locale for doing the comparison. If the current locale is C or POSIX, Strcoll function is equivalent to strcmp(). The function returns : 0 – if the two strings are exactly equivalent. <0 – if smaller byte is found in the string1. >0 –if smaller byte is found in the string2. Syntax: strcoll(string1,string2) string1 : Required. Specifies the first string. string2 : Required. Specifies the second string. Note : The PHP strcoll() function is case-sensitive...

strncmp in PHP

PHP strncmp() function is utilized to compares two string. The function returns : 0 – if the two strings are exactly equivalent. <0 – if smaller byte is found in the string1. >0 –if smaller byte is found in the string2. Syntax: strcmp(string1,string2) string1 : Required. Specifies the first string string2 : Required. Specifies the second string Tip: The PHP strncmp() function is binary safe and case-sensitive. Example: <?php echo strcmp("good morning","Good Morning"); ?> Output will be:...

strchr in PHP

 PHP strchr() function is utilized to find the first occurrence of a string inside another string (main string). If char cannot be found, this function returns FALSE.  It is an identical  to strstr() function. Syntax: strchr(string,search) string : Required. Specifies the input string to search search : Required. Specifies the string to search for. Note : PHP strchr() function is binary-safe and case-sensitive. For case-insensitive search, use stristr() function. Example: <?php echo strchr("Good Morning world!","Morning"); echo...

strcasecmp in PHP

 PHP strcasecmp() function is identical to strcmp() function, except that lowercase and uppercase Versions of the same letter compare as equal. strcasecmp() function returns : 0 – if the two strings are exactly equivalent. <0 – if smaller byte is found in the string1. >0 – if smaller byte is found in the string2. Syntax: strcasecmp(string1,string2) string1 : Required. Specifies the first string string2 : Required. Specifies the second string Tip : The PHP strcasecmp() function is binary safe and case-insensitive. Example: <?php echo...

str_word_count in PHP

PHP str_word_count() function is utilized to count the number of words in a string. Syntax: str_word_count(string,return,char) string : Required. Defines the input string. return : Optional. Defines the return value of the PHP str_word_count() char : Optional. Defines special characters to be considered as words Example:) <?php echo str_word_count("Good Morning."); echo "<br /><stromg> Example with an return parameter : </stromg><br />"; print_r(str_word_count("Good Morning Sam & John.",1)); echo "<br /><stromg>...