Here is a list of the most commonly used PHP String Functions while programming:

  • substr() function: This function is used in PHP to give you access to a substring having a specific start and endpoints within the string.
    Syntax:
    string substr(string string, int start[, int length] );
  • strlen() function: This function is used in PHP to check the character length of a string.
    Syntax:
    echo strlen(“string”)
  • str_replace() function: This function is used in PHP as a find and replace function within any string.
    Syntax: str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] ) : mixed
  • trim() function: This function is used in PHP to trim all the whitespace from the starting point to the endpoint in any
    string.
    Syntax: trim ( string $str [, string $character_mask = " \t\n\r\0\x0B" ] ) : string
  • strpos() function: This function is used in PHP to find the first occurrence of a substring within a string.
    Syntax: strpos ( string $haystack , mixed $needle [, int $offset = 0 ] ) : int
    In the above syntax, it actually commands PHP to find the first occurrence of the substring needle in the string haystack.
  • strtolower() function: This function is used in PHP to convert all the characters in a string to lowercase.
    Syntax: strtolower ( string $string ) : string
  • strtoupper() function: Well, obviously this function is used to convert all the characters in a string to the upper case.
    Syntax: strtoupper ( string $string ) : string

In the above command, it returns with part of the haystack string starting from the point of the needle to the end of the haystack.

Suggest An Answer