Jump to content

Test All Characters In A String


The Little Guy

Recommended Posts

I am using the code (at the bottom) to test some strings for non-US characters, the following code is returning:

 

int(0)
int(0)
int(0)

 

The result I am looking for is the first and thrid dump should be 0 and the second dump should be 1 like so:

 

int(0)
int(1)
int(0)

 

Here is my test code:

 

<?php
$str[] = '漢語';
$str[] = 'abc123';
$str[] = '漢語abc123';
foreach($str as $s){
    var_dump(preg_match("/^\p{Common}*$/u", $s, $matches));
}

 

What can I do to get the results of the second block?

Link to comment
https://forums.phpfreaks.com/topic/272241-test-all-characters-in-a-string/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.