PHP string function hebrevc

The String function hebrevc() converts Hebrew text from right-to-left (RTL) to left-to-right(LTR).

Syntax

Parameter Description
hebrew_str This is a required parameter which defines the Hebrew string.
chars_per_line  This is an optional parameter which defines the maximum characters for each line.

Return Value

It will return the visual string.

PHP Version: PHP 4, PHP 5, PHP 7

PHP string function str_repeat

The String function strpos() repeats a string for a specified number of times.

Syntax

Parameter Description
mystr This is a required parameter which defines the string to repeat.
multiplier This is a required parameter which defines the number of times the string will be repeated and the number should be >=0

Return Value

It will return the string after repeating it for the number of times specified in the multiplier parameter.

Example

PHP Version: PHP 4, PHP 5, PHP 7

PHP string function strip_tags

The String function strip_tags() removes the HTML, PHP and XML tags from the given string.

Syntax

Parameter Description
mystr This is a required parameter which defines the string to check.
tags This is an optional parameter which defines the allowable tags and these tags will not be removed from the string.

Return Value

It will return the string after removing the Tags.

Example

 

PHP string function rtrim

The String function rtrim() removed the white spaces or any other character from the right side of the string.

Syntax

Parameter Description
mystr This is a required parameter which defines the string to check.
 characters This is an optional parameter which defines the characters to remove from the string.

If we don’t define the 2nd parameter then this function will only will strip the following characters:

  • “\n” – a new line
  • “\t” – a tab
  • “\r” – a carriage return
  • “\x0B” – a vertical tab
  • “\0” – NULL values
  • ” ” – an ordinary blank space

Return Value

It will return the modified string as per the 2nd parameter.

Example

 

PHP string function soundex

The String function soundex() calculates the soundex key of any string.

Syntax

Parameter Description
mystring This is a required parameter which defines the string to check.

Return Value

It will return the soundex key of the string.

A soundex key is a four character alphanumeric string which represent English pronunciation of any word specified in the function.

Example

 

Note: This function may create the same key for the almost similar sounding words.

 

PHP string function strtoupper

The String function strtoupper() will convert all the lowercase letters to uppercase letters.

Syntax

Parameter Description
mystring This is a required parameter which defines the string to convert to uppercase letters.

Return Value

This function will return the whole string in uppercase letters.

Example

 

NOTE: This function is binary-safe.

 

PHP string function strncasecmp

The String function strncasecmp() is used to do a case insensitive string comparison.

Syntax

Parameter Description
mystr1 This is a required parameter which defines the first string to compare.
mystr2 This is a required parameter which defines the second string to compare.
len  This is a required parameter which defines the lenght of the string used to compare the two strings.

Return Value

This function will return < 0 if the mystr1 is less than mystr2; > 0 if mystr1 is greater than mystr2, and zero (0) if they are equal.

Example

Example 2

 

 

PHP string function strcspn

The String function strcspn() is used to count the number of characters including white spaces in a string.

Syntax

Parameter Description
mystring This is the required parameter which specifies the string to search.
char This is the required parameter which specifies characters to search for in the string.
start This is an optional parameter which specifies  from where in the string to start searching.
length This is an optional parameter which specifies  length of the string.

Return Value

It will returns the length of the string before any part of the specified character.

Example

NOTE: This function is binary-safe

PHP string function strlen

The String function strlen(), returns the length of the given string

PHP string function strlen

Syntax

Parameter Description
mystring This is a required parameter which defines the string to check

Return Value

It will return the length of the string on success and if string is empty it returns zero (0).

Example

 

NOTE: It returns number of bytes rather than number of characters.

NOTE: It returns NULL when executed on Arrays.

PHP string function strpos

The String function strpos(), finds the position of very first occurrence of any substring in the given string.

PHP string function strpos

Syntax

Parameter   Description
string_value This is a required parameter which defines the string to search.
sub_string_value This is a required parameter which defines the string to find.
start_position  This is an optional parameter which defines from where to begin the search.

Return Value

It will return the position of the sub string in the given string and return FALSE if sub string not found in the string.

Example 1 using === (Identical Operator)

Example 2 using !== (Not identical Operator)

Example 3 using an string start  position

 

NOTE: String position starts from zero (0) and not from one (1)

NOTE: This function is binary-safe.

PHP Version: PHP 4, PHP 5, PHP 7