![]() ![]() 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. Negative: If the passed integer is negative then the last N elements of the array will be cut off and it will return the remaining elements.Zero: If the passed integer is 0, then the array will contain the whole string as a single element. ![]() If you separate the string into more than N number of pieces regarding the delimiter, the first N-1 elements remain the same, and the rest of the elements combine to form a single element. Positive: If the passed integer is positive, then the array will store this many numbers of elements.This number can be positive, negative, or zero. This parameter represents the number of strings in which it should split the original string. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |