Write a program which will count the "t" characters in the text "techstudy"

Introduction

PHP is a server scripting language, and It is a powerful tool for making interactive and dynamic Web-pages. I have used WampServer 2.2 for following example.


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. <?php
  2. $text="techstudy";
  3. $searchchar="t";
  4. $count="0";
  5. for($x="0"; $x< strlen($text); $x++)
  6. {
  7. if(substr($text,$x,1)==$searchchar)
  8. {
  9. $count=$count+1;
  10. }
  11. }
  12. echo $count;
  13. ?>
  14.  

Result

python language techstudy.org

     





Related Topics




Popular Posts