Splitting characters, Words, Sentences using Preg_Split
Syntax : array preg_split ( string pattern, string subject [, int limit [, int flags]])
The following example illustrates splitting characters, words and sentences from input string using preg_split() funtion.
<?php
$input = ‘Hello user!. Welcome.’;
$split_chars = preg_split(’//’, $input);
print_r($split_chars);
echo “<p>”;
$split_words= preg_split(’/ /’, $input);
print_r($split_words);
echo “<p>”;
$split_sentences= preg_split(’/\./’, $input, -1 , PREG_SPLIT_NO_EMPTY);
print_r($split_sentences);
?>
