PHP strtok() Function

PHP strtok() Function

The strtok() function in PHP splits a string into smaller strings or tokenize the specified string. 

Syntax

strtok ( string $str , string $token )

Parameter

str(required)- This parameter represents the input string to split into smaller strings or tokens.

token(required)- It signifies the delimiter which is used in splitting up the str parameter.

Return

This function returns a string token.

Example 1





Output

 String: Hello User! How you have been?
 Removing the spaces in between the string
 New string: HelloUser!Howyouhavebeen? 

Example 2





Output

 String: Hello User! How you have been?
 Returned string: Hello User 

Example 3





Output

Students List: Reema
 Rahul
 Varun
 Amar
 Shivam
 Radha 

Related Topics

PHP array_pop() Function

PHP array_pop() Function The array_pop() function in PHP pops or removes the last element from the array shortening the array by one element. Syntax array_pop ( array &$array ) Parameter array(required)- This parameter represents the input array to get the value...

1 minute read.

PHP gettype() Function

PHP gettype() Function The gettype () function in PHP gets the type of the specified variable. Syntax gettype ( mixed $var ) Parameter var(required)- This parameter represents the variable being type checked. Return This function returns the type of the PHP variable specified by “var”...

1 minute read.

PHP soundex() Function

PHP soundex() Function The soundex() function in PHP Calculates the soundex key(four character long alphanumeric string that represent English pronunciation of a word) of a string. Syntax soundex ( string $str ) Parameter str(required) – This parameter represents the input string. Return This function returns the soundex...

1 minute read.

PHP Associative Arrays

PHP associate array is used to access the elements with keys by “=>” symbol. There are two ways to create an associative array. 1st way: $age = array("John"=>"20", "Helena"=>"30", "Rasmus"=>"29"); 2nd way: $age['john'] = "20"; $age['Helena'] =...

1 minute read.

PHP array_intersect_assoc() function

PHP array_intersect_assoc() function The array_intersect_assoc() function in PHP is used to compute the intersection of arrays with the help of an additional index check. It returns an array containing all the entries from array1 that are present...

1 minute read.

PHP array_key_exists() function

The array_key_exists () function in PHP is used to check whether the specified key exists in the array or not. It returns a Boolean value TRUE if the given key exists else it returns FALSE. Syntax array_key_exists(mixed key,array$array) Parameter key(required)- This...

1 minute read.

PHP isset() function

PHP isset is used to check whether the variable is set or not.The PHP isset() function returns false if variable contains a NULL value. Syntax: isset(variable1, variable2….) Presentation of PHP isset: In...

2 minutes read.

PHP strnatcasecmp() Function

PHP strnatcasecmp() Function The strnatcasecmp() function in PHP compares two strings using a "natural" algorithm. It is a case-insensitive function. Syntax strnatcasecmp ( string $str1 , string $str2 )  Parameter str1(required)- This parameter represents the first string. str2(required)- This parameter represents the second string. Return This function returns a value less...

1 minute read.

PHP wordwrap() Function

PHP wordwrap() Function The wordwrap() Function wraps a string to a given number of characters using a string break character. Syntax wordwrap ( string $str [, int $width [, string $break  [, bool $cut  ]]] ) Parameter str(required)- This parameter specifies the input string.       width(optional)- This parameter represents the number of...

1 minute read.

PHP rsort() Function

PHP rsort() Function The rsort () function in PHP is used to sort an array in reverse order i.e., highest to lowest. Syntax rsort ( array &$array [, int $sort_flags = SORT_REGULAR ] ) Parameter array(required)- This parameter represents the input array. sort_flags (optional)- This parameter is used to...

1 minute read.

PHP Functions

PHP functions are used to reuse piece of code many times.  There are various built-in functions in PHP. A function will be executed by a call to the function. Following are...

3 minutes read.

PHP ucfirst() Function

PHP ucfirst() Function The ucfirst() function in PHP converts the first character of the specified string to uppercase. Syntax ucfirst ( string $str ) Parameter str(required)- This parameter represents the input string. Return This function returns a string with the first character of the specified string capitalized if that...

1 minute read.

PHP krsort() Function

PHP krsort() Function The krsort() function in PHP sorts an array by key in reverse order while maintaining the keys. Syntax krsort (array & $array[,int $sort_flags= SORT_REGULAR] ) Parameter array(required)- This parameter represents the input array. sort_flags(optional)- This...

3 minutes read.

PHP is_long() Function

The PHP is_long () function in PHP is used to find whether a variable is an integer or not. It returns a Boolean value true if the parameter var is integer else it returns...

1 minute read.

PHP substr_replace() Function

PHP substr_replace() Function The substr_replace() function in PHP replaces a part of a string with another string. Syntax substr_replace (mixed $string , mixed $replacement , mixed $start [, mixed $length ] ) Parameter string(required)- This parameter represents the input string. replacement(required)- This parameter signifies the string to replace with. start(required)-...

2 minutes read.

PHP Array Functions

There are various array functions in PHP. They are used to access and manipulate the elements ofan array. Following are functions of array. Array Function Description array() It is used to create an array. array_change_key_case() It is...

3 minutes read.

PHP String get_html_translation_table() Function

The get_html_translation_table() function in PHP is used to return the translation table used by the htmlentities() and htmlspecialchars() functions. Syntax get_html_translation_table ([ int $table = HTML_SPECIALCHARS [, int $flags = ENT_COMPAT | ENT_HTML401 [, string $encoding = "UTF-8" ]]] ) Parameter table (optional)- This parameter specifies which translation table to return. It...

2 minutes read.

PHP bin2hex() Function | Convert Binary to Hexadecimal

PHP bin2hex() Function The bin2hex() function in PHP converts the specified string value of ASCII characters to hexadecimal value. Syntax bin2hex(str) Parameter str(Required): This parameter represents the string to be converted into hexadecimal. Return  This function returns...

1 minute read.

PHP array_flip() function

PHP array_flip() function The array_flip() function in PHP exchanges all keys with their associated values in an array and returns an array in flip order. If the specified value has several occurrences, the latest key will be...

1 minute read.

PHP pos() Function

PHP pos() Function The pos() function in PHP returns the current element in an array which is initialized to the first element of the array. This function is an alias of current(). Syntax pos ( array...

1 minute read.