Verwenden mb_substr_count (für die Anzahl der Teilzeichen Vorkommen zählen).
//Function to return array of check emoticons...
function emoticons() {
$arrIcons = array(
':)',
':-)',
':D',
':d',
';)',
':P',
':-P',
':-p',
':p',
':(',
':o',
':O',
':0',
':|',
':-|',
':/',
':-/'
);
return $arrIcons;
}
//Check for emoticons...
$maxAllowIcon = 25;
$txtMYTEXTBOX = $_REQUEST['MYTEXTBOX'];//Get textbox inputed value...
$arrExistIcon = emoticons();//Get predefined icons...
//Check for how many emoticons used...
$cntEmoticons = 0;
foreach($arrExistIcon AS $keyImoticons => $emotIcons){
$cntEmoticons += mb_substr_count($txtMYTEXTBOX, $emotIcons);
}
//If icons more then maximum allowed then print message...
if($cntEmoticons > $maxAllowIcon){
print('ERROR :: Maximum ' . $maxAllowIcon . ' emoticons allowed');
exit;
}
Haben Sie etwas versucht? – Pierre
Hast du meine Antwort überprüft? –