PHP Implode() Function24 Mar 2025 | 2 min read PHP implode() is a string function, which joins the array elements in a string. It is a binary-safe function. In implode() function, parameters can be passed in any order. The implode() function works same as the join() function and returns a string created from the elements of the array. Basically, this function joins all elements of array in one string. SyntaxThere are two syntax are available for implode() function, which are given below: or Join the array elements by $glue string parameter. ParametersThere are two parameters can be passed in the implode() function, one of which is mandatory, and another one is optional. These parameters are as follows: $glue (optional): It is an optional and string type of parameter. It contains the value to join the array elements and form a string. Basically, $glue is used to join the string. $pieces (mandatory): This parameter contains the array of string to implode. The array elements are mandatory to pass in implode() function to join into one string. Return ValueThe implode() function returns the string formed from the array elements. The string will be formed in the same order as elements passed into array. The return type of this function is string. ChangesAfter PHP version 7.4.0, passing the $glue parameter after the $pieces parameter has been deprecated. ExamplesExample 1: In the below example, array elements are joined with + operator using implode() function. Output: Before using 'implode()' function: array('Welcome', 'to', 'PHP', 'tutorial') After using 'implode()' function: Welcome+to+PHP+tutorial Example 2: Output: Noida, Delhi, Gurugram NoidaDelhiGurugram Example 3: In the below example, two arrays are joined together using implode() function. Output: Hello everyone! / Welcome to Javatpoint Next TopicPHP String |
PHP Function PHP function is used to convert a string hexadecimal value to ASCII ccharacters. Note: This function does not convert a hexadecimal number to a binary number. Syntax: string hex2bin ( string $data ) Parameter Description Required/Optional String Specify the hexadecimal value to be converted. required Example 1 <?php echo hex2bin("48656c6c6f20576f726c6421"); ?> Output: Hello World! Example 2 <?php $hex = hex2bin("6578616d706c65206865782064617461"); var_dump($hex); ?> Output: string(16) "example...
1 min read
PHP string Function The is in-built function of PHP. It is used to return information about words used in a string or counts the number of words in a string. Syntax: str_word_count(string,return,char) Parameter Description Required/Optional string Specify the string to check. Required. return Specify the return value of the function. Values: 0 : It is by default...
1 min read
PHP Function PHP function is predefined string function, which is used to encodes a string using the uuencode algorithm. It returns the uuencoded data. Note: By using "Uuencoded function" the uuencoded data is 35% larger than the original. Syntax: convert_uuencode(string) Parameter Description Required/Optional String The string to uuencode Required Example 1 <?php // encode the string $str2...
1 min read
PHP explode() is a string function, which splits a string by a string. In simple words, we can say that it breaks a string into an array. The explode() function has a "separator" parameter, which cannot contain an empty string, because it holds the original...
3 min read
PHP String Function The function is a built-in function of PHP, which converts a quoted-printable string to an 8-bit string. This function returns back an 8-bit binary string. The function is similar to the imap_qprint() function and opposite to the quoted_printable_encode() function. The syntax...
1 min read
PHP string Function PHP string is predefined function. It is used to convert first byte of string to a value between 0 and 255. It returns ASCII value. Syntax: int ord ( string $string ); Parameter Description Required/Optional string Specify string value required Example 1 <?php echo "Your Value is: A"."<br>"; echo "By using '' Function:".ord("A")."<br>"; ?> Output: Your Value...
1 min read
PHP string levenshtein() Function PHP string levenshtein() function is in-built function. It is used to calculate the distance between two strings. By default, PHP provides some operations (replace, insert and delete) It returns the Levenshtein distance between the two argument strings or -1, if the string exceeds 255...
1 min read
PHP Function The function is used to remove whitespace or other predefined character from the right end of a string. Syntax: chop(string,charlist); Note: function is different than the Perl function function, which is used to remove the last character in the string. Parameter Description Required/Optional string the string to be check Required charlist charlist...
1 min read
PHP string Function PHP string is predefined function.It is used to calculate the SHA-1 hash of a string. It uses US secure Hash Algorithm 1. SHA-1 produces a 160-bit output called a message digest. Note: To calculate the SHA-1 hash of a file, use the sha1_file()function. Syntax: sha1(string,raw); Parameter Description Required/Optional String Specify...
1 min read
PHP string join() Function PHP string join() is predefined function. It is used to return a string from the elements of an array. It is an alias of the implode() function. Syntax: join(separator,array) Parameter Description Required/Optional separator Specify the array element optional array The array to join to a string required Example 1 <?php $arr = array('Hello','PHP','Join','Function'); echo join(" ",$arr)."<br>"; ?> Output: Hello PHP Join...
1 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India