note 96893 added to control-structures.for
| From: | kanirockzatgmaildotcom at osu1 dot php dot net | Date: | Sun, 21 Mar 2010 19:49:03 +0000 |
| Subject: | note 96893 added to control-structures.for | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-167278@lists.php.net to get a copy of this message | ||
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)
----
Server IP: 69.147.83.197
Probable Submitter: 66.28.139.243
----
Manual Page -- http://www.php.net/manual/en/control-structures.for.php
Edit -- https://master.php.net/note/edit/96893
Del: integrated -- https://master.php.net/note/delete/96893/integrated
Del: useless -- https://master.php.net/note/delete/96893/useless
Del: bad code -- https://master.php.net/note/delete/96893/bad+code
Del: spam -- https://master.php.net/note/delete/96893/spam
Del: non-english -- https://master.php.net/note/delete/96893/non-english
Del: in docs -- https://master.php.net/note/delete/96893/in+docs
Del: other reasons-- https://master.php.net/note/delete/96893
Reject -- https://master.php.net/note/reject/96893
Search -- https://master.php.net/manage/user-notes.php