What are the different parameters that can be used in the explode function in PHP to extract the first word of a string?
To extract the first word of a string using the explode function in PHP, you can use the space character (" ") as the delimiter parameter. This will split the string into an array of words, and you can then access the first element of the array to get the first word.
$string = "Hello World";
$words = explode(" ", $string);
$firstWord = $words[0];
echo $firstWord; // Output: Hello
Related questions
-
regular expressions PHP searching
-
opendir PHP error
-
PHP echo statement parentheses