Re: preg_match problem

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

 



I do not exactly understand what you are trying to achieve.
Is it something like this?

foreach($output as $key => $val)
    print "$key = $val";




Raul Berina <raul_berina_fq@xxxxxxxxx> wrote:                               One last how can split and print this like this (A) from array (B):
 
 A. 
 last => "Davis" 
 first => "Nathan" 
 middle = "Ventura"
 
 B
 $output["last"] = "<last name>";
 $output["first"] = "<first name>";
 $output["middle"] = "<middle name>";
 $output["suffix"] = "<suffix name>";
 
 Raul Berina <raul_berina_fq@xxxxxxxxx> wrote:                               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]
  
  
      
                                
 
 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]
 
 
     
                               


Victor Navarro
http://www.vicxsite.com/

       
---------------------------------
Never miss a thing.   Make Yahoo your homepage.

[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