Re: [PHP] regex - filtering out chinese utf8 characters

2009-07-30 Thread Stuart Connolly

Hi Merlin,

I think the pattern you're looking for is '/[a-zA-Z0-9]/' which will  
match all alphanumeric characters.


Cheers

Stuart

On 30 Jul 2009, at 19:13, Merlin Morgenstern wrote:


Hi there,

I am trying to filter out content that is not ascii. Can I do this  
with regex? For example:


$regex = '[AZ][09]';
if (preg_match($regex, $text)) {
return TRUE;
}
else {
return FALSE;
}

The reason I need to do this is that I am doing a mysql query with  
the text and I need to make sure it is not UTF8. Otherwise I do get  
following error:


Error: 		Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and  
(utf8_general_ci,COERCIBLE) for operation '='


I am new to regex and would be happy for a jump start to get this  
fixed.


Best regards, Merlin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





smime.p7s
Description: S/MIME cryptographic signature


Re: [PHP] String to Date Conversion Problem

2009-07-31 Thread Stuart Connolly

Hi Alice,

Based on the string format that you mentioned (DD MMM YY - DAY) you  
should be able to transform to any other date using the following:


$parts = explode(' ', '23 JUL 09 - THURSDAY');

echo date('m/d/Y', strtotime("{$parts[1]} {$parts[0]} {$parts[2]}"));

Cheers

Stuart

On 31 Jul 2009, at 15:19, Alice Wei wrote:



Hi, Guys:

 I am trying to turn a prepared line into a date format, and the  
string looks something like this: 23 JUL 09  -  THURSDAY, and I am  
trying to change the string to a mm/dd/ format that looks like  
07/23/2009.


 I tried to use strtotime() but it gave me nothing.
 Here is the code:

   list($date,$month,$year,$dash,$day) = split(" ",$line,5);
   echo "" . strtotime($date . "\s" . $month . "\s" .  
$year). "";


 Could anyone on the list please give me a hint on what I might have  
done wrong here?


Thanks for your help.

Alice










_
All-in-one security and maintenance for your PC.  Get a free 90-day  
trial!

http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=wl_wlmail




smime.p7s
Description: S/MIME cryptographic signature