Need PHP expression help

This is a discussion on Need PHP expression help within the PHP Language forums, part of the PHP Programming Forums category; Hi, I need to validate a string of text against an expression and having difficulty putting it together. Basically, I ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-26-2005
Ragnorack67@hotmail.com
 
Posts: n/a
Default Need PHP expression help

Hi, I need to validate a string of text against an expression and
having difficulty putting it together. Basically, I want to count the
number of words in a string that are separated by commas. If the count
is more than a predetermined number 9, it will do something, else
something else. Thank you for assistance.

Reply With Quote
  #2 (permalink)  
Old 02-26-2005
Ken Robinson
 
Posts: n/a
Default Re: Need PHP expression help


Ragnorack67@hotmail.com wrote:
> Hi, I need to validate a string of text against an expression and
> having difficulty putting it together. Basically, I want to count the
> number of words in a string that are separated by commas. If the

count
> is more than a predetermined number 9, it will do something, else
> something else. Thank you for assistance.


How about
<?
$tmp = explode(',',$your_str);
if (count($tmp) > 9) {
// do something
} else {
// do something else
}
?>

Ken

Reply With Quote
  #3 (permalink)  
Old 02-26-2005
Ragnorack67@hotmail.com
 
Posts: n/a
Default Re: Need PHP expression help

Very nice, that did the trick. :) Cheers!

-Alex

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 10:58 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0