السلام عليكم
اريد كود ب php او جافاسكربت لحساب عدد الكلمات في صفحة
يوجد بها اكثر من 200 كلمة على شكل اسماء
مثال:
khaled
ahmed
rachid
mohamed
said
.... الخ
يمكنك استخدام هذه الدالة:
<?php
// PHP program to count number
// of words in a string
// Function to count the words
function get_num_of_words($string) {
$string = preg_replace('/\s+/', ' ', trim($string));
$words = explode(" ", $string);
return count($words);
}
$str = " Geeks for Geeks ";
// Function call
$len = get_num_of_words($str);
// Printing the result
echo $len;
?>
التعليقات