The preg_split() is also an in-built PHP function that is used to convert a string into an array by splitting it into smaller substrings. The comma “,” is passed to the explode() function as a delimiter to convert the string into array elements. In the above example, you are converting a string containing three colors separated by a comma to an array. The following example illustrates the working of the explode() function to convert string to array in PHP. Example Input:Įxplode(“ “, “Hello, what is your name?") Output:Įxplode(“ “, “Hello, what is your name?", 3) Output:Įxplode(“ “, “Hello, what is your name?", -1) Output: The explode() function returns an array that contains the string pieces as its elements.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |