This is a discussion on "count of the elements" within the PHP Forum section. This forum, and the thread "count of the elements are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
count of the elements
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
count of the elements
hi,
all one very basic question?? how should i count the particular elements in a string?? for example $content="Mr.Bush, is the President of U.S." in the above string i want to count "." so how should i proceed?? regards amit |
|
|
|
||||
|
Re: count of the elements
one method... and probabally not the best (I know extremely little PHP) is to store the length of the string in a variable..
next, replace "." with ".." number of "."'s = current length of string minus the original length. PHP Probabally has a native function to do this, but the above is one method.
__________________
Rob - SEO Specialist Owner & Founder of Webforumz.com I am currently unavailable for private work
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
||||
|
Re: count of the elements
the native function is substr_count, the php manual for this is here: http://uk2.php.net/substr_count
|
![]() |
| Tags |
| count, elements |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Please Help with (should be) simple count() query. | MrQuestions | Databases | 2 | Mar 23rd, 2008 20:42 |
| Oh No! Post Count Dropped? | karinne | Webforumz Cafe | 1 | Sep 25th, 2007 20:28 |