Afternoon all, I've been playing around with the AUG php for marketing lists that limits the number of words. I've added a line to stop the words being repeated for use to generate a page title, but have a problem if the word original word count is less than the defined cut off.
If $sOrigininal has fewer than the 12 words defined in $nCount, then I get the error:
I whole heartedly admit that I know nothing about php and would be grateful if someone would tell me where I've gone wrong.
PHP Code:
$sShort = "";
$nCount = 0;
$sOriginal = "some string";
foreach(explode(" ", $sOriginal) as $sWord)
{
if ($nCount > 12)
{
$sShort .= "...";
break;
}
if (strpos($sShort, $sWord) !== false) continue;
$sShort .= $sWord . " ";
}
echo $sShort;
Warning: strpos(): Empty delimiter. in main on line 12
Comment