How do you seperate a string by space in php?
(PHP 4, PHP 5, PHP 7, PHP 8) Show explode — Split a string by a string Descriptionexplode(string Parametersseparator The boundary string. string The input string. limit If If the If the
Return Values Returns an
array of strings created by splitting the If Changelog
ExamplesExample #1 explode() examples
$data = "foo:*:1023:1000::/home/foo:/bin/sh"; Example #2 explode() return examples
The above example will output: array(1) ( [0] => string(5) "hello" ) array(2) ( [0] => string(5) "hello" [1] => string(5) "there" ) array(2) ( [0] => string(0) "" [1] => string(0) "" ) Example #3
The above example will output: Array ( [0] => one [1] => two|three|four ) Array ( [0] => one [1] => two [2] => three ) Notes
See Also
Gerben ¶ 6 months ago
= ''; bocoroth ¶ 1 year ago
henrik Schmidt ¶ 1 year ago
Emilio Bravo ¶ 1 year ago
joshuachidiebere17217 at gmail dot com ¶ 7 months ago
David Spector ¶ 1 year ago
How do you split a string in space?To split a string with space as delimiter in Java, call split() method on the string object, with space " " passed as argument to the split() method. The method returns a String Array with the splits as elements in the array.
What is split () in PHP?PHP - Function split()
The split() function will divide a string into various elements, the boundaries of each element based on the occurrence of pattern in string.
How do you separate a string?The split() method splits a string into an array of substrings. The split() method returns the new array. The split() method does not change the original string. If (" ") is used as separator, the string is split between words.
How do I separate comma separated values in PHP?Use explode() or preg_split() function to split the string in php with given delimiter. PHP | explode() Function: The explode() function is an inbuilt function in PHP which is used to split a string in different strings.
|