List Info

Thread: note 74683 added to function.count-chars




note 74683 added to function.count-chars
user name
2007-04-23 09:31:40
a function which counts the number of a character in a
string:

function countCharInString($str,$chr)
{
     foreach(count_chars($str) as $el=>$val)
     	if(chr($el)==$chr)
           return $val;
     return 0;
}

echo countCharInString("hello
world","l");
this will output: 
3
----
Server IP: 69.147.83.197
Probable Submitter: 195.22.236.216
----
Manual Page -- http://www.php.net/manual/en/function.count-chars.php
Edit        -- https://master
.php.net/note/edit/74683
Del: integrated  -- h
ttps://master.php.net/note/delete/74683/integrated
Del: useless     -- http
s://master.php.net/note/delete/74683/useless
Del: bad code    -- htt
ps://master.php.net/note/delete/74683/bad+code
Del: spam        -- https:/
/master.php.net/note/delete/74683/spam
Del: non-english -- 
https://master.php.net/note/delete/74683/non-english
Del: in docs     -- http
s://master.php.net/note/delete/74683/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/74683
Reject      -- https://mast
er.php.net/note/reject/74683
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )