ENGLISH
Hello guys my name is Sinan Karayaman. I have been working on wordpress and other web services for few years now.Now lets begin how to create kelime sayacı step by step.
How to create kelime sayacı?
TÜRKÇE
Merhaba arkadaşlar ben Sinan Karayaman.Bugün sizlere php ile kelime sayacı nasıl oluşturulur onu anlatacağım.Kelime sayacı vereceğiniz metindeki kelimelerin kaç kere kullanıldığını alt alta listeler.
<!DOCTYPE html>
<html>
<head>
<title>Kelime Saydırma</title>
</head>
<body>
<?php
/*
sinan karayaman
20.12.2017
*/
function KelimeleriSay($Kelimeler){
$KelimelerParcala = explode(" ", $Kelimeler);
$Sonuc = array();
foreach ($KelimelerParcala as $Kelime) {
$Say = 0;
foreach ($KelimelerParcala as $Kontrol) {
if($Kelime === $Kontrol){
$Say++;
}
}
$Sonuc[] = $Kelime." Kelimesi ".$Say." Tane Var";
}
$Sonuc = array_unique($Sonuc);
$Sonuc = implode("<br>", $Sonuc);
return $Sonuc;
}
$Kelimeler = 'kontrol amaçlı ornek metin girdim sinan karayaman ornek dosyaya yazdım programda herhangi bir problem var mı diye kontrol ediyorum sinan karayaman';
$KelimeleriSaydir = KelimeleriSay($Kelimeler);
echo $KelimeleriSaydir;
?>
</body>
</html>
*15. Satırda bulunan explode fonksiyonu ile kelimeleri boşluklardan ayırarak array yani dizilere aktarıyoruz.
*18 satırda ise 15. satır daki dizileri foreach yardımı ile döngü içine aktarıyoruz.
*20 .Satırda ise kelimeleri saymak için $Say adında bir değişken aktarıyoruz.
*21. ve 23. Satırda ise, $Kelimelerin tekrar foreach yardımı ile kelime var mı yok mu diye tekrar kontrol ediyor.
*25. satırda ise yukarıdaki şartlar sağlanıyor $Say değişkenini +1 artırıyoruz.
*31. Satırda ise $Sonuc dizisine $Kelimenin kaç kere tekrar edildiğini aktarıyoruz.
*35. Satırda ise $Sonuc dizisinde de tekrar edenleri array_unique fonksiyonun yardımı ile siliyoruz.
*36. Satırda ise implode ile dizileri birleştirip string değere çeviriyoruz.
*38. Satırda ise $Sonuc değişkenini return ettiriyoruz.
*42. Satırda $Kelimeler değişkenine örnek kelimeler veriyoruz.
*44. Satırda bu kelimeleri 13. satırdaki KelimeleriSay fonksiyonumuza veriyoruz
*45. Satırda KelimeleriSay fonksiyonundan gelen yanıtı ekrana basıyoruz.
Sonuç ekrana bu şekilde basılıyor.
Github : https://github.com/php/php-src
Posted on Utopian.io - Rewarding Open Source Contributors
good,,,
Thank you for the contribution. It has been approved.
You can contact us on Discord.
[utopian-moderator]
eline sağlık
teşekkür ederim
Hey @sinankarayaman I am @utopian-io. I have just upvoted you!
Achievements
Suggestions
Get Noticed!
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x