- print_r: documentation ( source)
- array_merge: documentation ( source)
- array_shift: documentation ( source)
- explode: documentation ( source)
- str_split: documentation ( source)
<?php
$inStr = 'Hey you. guys';
$tokens = array();
$tokenList = explode(' ',$inStr);
foreach($tokenList as $bigToken) {
$tokens[] = $bigToken; //take care of individual words
$tokens = array_merge($tokens, str_split($bigToken)); //take care of single letters
for($i = 2; $i < strlen($bigToken); $i++) {
$tempArr = str_split($bigToken, $i);
$tokens[] = array_shift($tempArr); //only need the first element here.
}
}
print_r($tokens);