count of the elements

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.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Dec 6th, 2005, 11:26
Junior Member
Join Date: Dec 2005
Age: 29
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote

  #2 (permalink)  
Old Dec 6th, 2005, 11:35
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
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
Reply With Quote
  #3 (permalink)  
Old Dec 6th, 2005, 16:21
benbacardi's Avatar
Highly Reputable Member
Join Date: Feb 2004
Location: United Kingdom
Age: 20
Posts: 611
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to benbacardi Send a message via Skype™ to benbacardi
Re: count of the elements

the native function is substr_count, the php manual for this is here: http://uk2.php.net/substr_count
Reply With Quote
Reply

Tags
count, elements

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 01:52.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43