I would like to split a text into single words using PHP. Do you have any idea how to achieve this?
My approach:
function tokenizer($text) {
$tex
you can also use PHP strtok() function to fetch string tokens from your large string. you can use it like this:
$result = array();
// your original string
$text = 'This is an example text, it contains commas and full stops. Exclamation marks, too! Question marks? All punctuation marks you know.';
// you pass strtok() your string, and a delimiter to specify how tokens are separated. words are seperated by a space.
$word = strtok($text,' ');
while ( $word !== false ) {
$result[] = $word;
$word = strtok(' ');
}
see more on php documentation for strtok()