Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #15897
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: count chars but not using count_chars |
| Date | 2015-11-14 12:51 +0100 |
| Organization | PointedEars Software (PES) |
| Message-ID | <3721621.oV0pfa5JrY@PointedEars.de> (permalink) |
| References | <n2736a$vt0$3@speranza.aioe.org> |
albert wrote:
> If have "Hello World World"
> how can count the spaces number?
>
> I founded this
> $str = "Hello World World";
> $strArray = count_chars($str,1);
>
>
> but is necessary to create more code for to have the value
> foreach ($strArray as $key=>$value)
> {echo "The character ".chr($key)."was found $value time";}
>
> and filter the $key
>
> there isn't a directly function?
You can use a regular expression to count non-overlapping substrings, which
can be single characters too:
<http://php.net/preg_match_all>
Please read at least the PHP manual and PHP FAQs before you post here.
You appear to have difficulties expressing yourself in English; know then
that this is an *international* newsgroup, and you can also use your native
language here. The PHP manual is available is several languages, too.
It is also likely that there is a PHP newsgroup in your native language or
for your home region, which you should prefer then; my newsserver also
carries the following newsgroups:
<news:cn.comp.lang.php> (Mandarin – 中文)
<news:cz.comp.lang.php> (Czech – Čeština)
<news:de.comp.lang.php> (German – Deutsch)
<news:dk.edb.internet.webdesign.serverside.php> (Danish – Dansk)
<news:es.comp.lenguajes.php> (Spanish – Español)
<news:fr.comp.lang.php> (French – français)
<news:it.comp.www.php> (Italian – Italiano)
<news:no.it.programmering.php> (Norwegian – Norsk)
<news:pl.comp.lang.php> (Polish – Polski)
<news:tw.bbs.comp.lang.php> (Mandarin, Taiwan-specific)
I am a regular both in <news:de.comp.lang.php> and here.
Please post here using your real name (at least first name *and* last name);
it is considered polite.
Your sender address is invalid; please fix this:
<http://www.interhack.net/pubs/munging-harmful/>
--
PointedEars
Zend Certified PHP Engineer
Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
count chars but not using count_chars albert <alstopspam@stopaspam.com> - 2015-11-14 11:42 +0100
Re: count chars but not using count_chars Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-11-14 12:51 +0100
Re: count chars but not using count_chars Jerry Stuckle <jstucklex@attglobal.net> - 2015-11-14 09:09 -0500
Re: count chars but not using count_chars Matthew Carter <m@ahungry.com> - 2015-11-14 23:08 -0500
Re: count chars but not using count_chars Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-11-17 21:35 +0100
csiph-web