Re: preg_match problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thank you very much! Is help a lot

Alligator <alligator_666@xxxxxxxxx> wrote:                               Use preg_match_all, for example:
 
 <?php
 
 $s1 = 'Davis, Nathan Ventura';
 $s2 = 'Davis, Nathan, Ventura';
 $s3 = 'Davis Nathan Ventura';
 
 $r1 = justOneComma($s1);
 $r2 = justOneComma($s2);
 $r3 = justOneComma($s3);
 
 echo "$s1 = " . ($r1 ? 'true' : 'false') . "<br/>";
 echo "$s2 = " . ($r2 ? 'true' : 'false') . "<br/>";
 echo "$s3 = " . ($r3 ? 'true' : 'false') . "<br/>";
 
 function justOneComma($pStr)
 {
     return preg_match_all('/,/', $pStr, $mt1) == 1;
 }
 
 ?>
 
 Hope this helps
 
 Alligator_666
 http://www.vicxsite.com/
 
 Raul Berina <raul_berina_fq@xxxxxxxxx> wrote:                               Hello,
  
  How can I check the string value using preg_match()?
  
  The name inputted should have exactly one comma (,). If 0, 2, or more commas are encountered, return FALSE,
  
  Sample:
  
  Davis, Nathan Ventura = True
  Davis, Nathan, Ventura = False
  Davis Nathan Ventura = False
  
  Your help is appreciated.
  
  Raul  
  
  LearnCareGo missions mobilization for local churches
  
  ---------------------------------
  Be a better friend, newshound, and know-it-all with Yahoo! Mobile.  Try it now.
  
  [Non-text portions of this message have been removed]
  
  
      
                                
 
 ---------------------------------
 Be a better friend, newshound, and know-it-all with Yahoo! Mobile.  Try it now.
 
 [Non-text portions of this message have been removed]
 
 
     
                               


 
LearnCareGo missions mobilization for local churches

 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

[Non-text portions of this message have been removed]


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux