how to convert a string in array in php i.e
$str="this is string";
should be like this
arr[0]=this arr[1]=is arr[2]=string
The str_split($str, 3);
splits the string in 3 character word but I need to convert the string after whitespace in an array.
The str_split() is an inbuilt function in PHP and is used to convert the given string into an array.
Definition and UsageThe implode() function returns a string from the elements of an array. Note: The implode() function accept its parameters in either order. However, for consistency with explode(), you should use the documented order of arguments. Note: The separator parameter of implode() is optional.
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.
Use explode function
$array = explode(' ', $string);
The first argument is delimiter
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With