note 96893 deleted from control-structures.for by sobak
| From: | sobak@php.net | Date: | Tue, 22 Nov 2016 08:29:08 +0000 |
| Subject: | note 96893 deleted from control-structures.for by sobak | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-207485@lists.php.net to get a copy of this message | ||
Note Submitter: kanirockz at gmail dot com
----
Here is another simple example for " for loops"
<?php
$text="Welcome to PHP";
$searchchar="e";
$count="0"; //zero
for($i="0"; $i<strlen($text); $i=$i+1){
if(substr($text,$i,1)==$searchchar){
$count=$count+1;
}
}
echo $count
?>
this will be count how many "e" characters in that text (Welcome to PHP)