Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function allowed_chars($text){
- $allowed = array(
- "1","2","3","4","5","6","7","8","9","0",
- "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",
- "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",
- "ا","أ","إ","آ","ض","ص","ث","ق","ف","غ","ع","ه","خ","ح","ج","د","ش","س","ي","ب","ل","ت","ن","م","ك","ط","ئ","ء","ؤ","ر","ى","ة","و","ز","ظ","ذ"
- ," ","-","_"
- );
- $splitted = str_split_utf8($text);
- $text = "";
- foreach($splitted as $letter){
- if(in_array($letter,$allowed)){
- $text .= $letter;
- }
- }
- return $text;
- }
- function str_split_utf8($str) {
- // place each character of the string into array
- $split=1;
- $array = array();
- for ( $i=0; $i < strlen( $str ); ){
- $value = ord($str[$i]);
- if($value > 127){
- if($value >= 192 && $value <= 223)
- $split=2;
- elseif($value >= 224 && $value <= 239)
- $split=3;
- elseif($value >= 240 && $value <= 247)
- $split=4;
- }else{
- $split=1;
- }
- $key = NULL;
- for ( $j = 0; $j < $split; $j++, $i++ ) {
- $key .= $str[$i];
- }
- array_push( $array, $key );
- }
- return $array;
- }
- //Enjoy it :) Khashabawy.com
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement