Verifying character set

Discussion in 'PHP' started by Kennedy, Mar 17, 2008.

  1. #1
    I have an array that has a few items that contain Arabic characters (example: Ø´Ú©Ù†).

    I want to delete only the items that contain these characters, but I'm not sure how to do this.

    Any ideas? Thanks in advance!
     
    Kennedy, Mar 17, 2008 IP
  2. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #2
    If you want to limit entries to ASCII characters, and you have mbstring loaded, you can use mb_detect_encoding.

    <?php
    $strs = array(
    	'algún', //Accented characters -- UTF-8
    	'algun', //ASCII
    	'Ø´Ú©Ù†' //UTF-8
    );
    
    foreach($strs as &$str)
    {
    	echo mb_detect_encoding($str) . '<br/>';
    }
    ?>
    Code (markup):
     
    joebert, Mar 17, 2008 IP