Beispiel #1
0
 public function compare($oldText, $newText)
 {
     $this->content = array();
     $this->wordIndices = array();
     $this->oldWords = $this->ConvertHtmlToListOfWords(str_split_utf8($oldText));
     $this->newWords = $this->ConvertHtmlToListOfWords(str_split_utf8($newText));
     $this->wordIndices = $this->IndexNewWords($this->newWords);
     $operations = $this->Operations();
     //print_r($this->wordIndices);
     //print_r($this->newWords);
     foreach ($operations as $item) {
         $this->PerformOperation($item);
     }
     return implode('', $this->content);
 }
Beispiel #2
0
            $split = 1;
        }
        $key = NULL;
        for ($j = 0; $j < $split; $j++, $i++) {
            $key .= $str[$i];
        }
        array_push($array, $key);
    }
    return $array;
}
error_reporting(0);
if ($_POST['submit']) {
    $arr = file($_FILES['file']['tmp_name']);
    $bword = $_POST['bword'];
    foreach ($arr as $line) {
        $lineArray = str_split_utf8(trim($line));
        sort($lineArray);
        $result[$line] = implode('', $lineArray);
    }
    $result = array_unique($result);
    echo implode('<br>', array_keys($result));
    die;
}
?>

<form name="word" action="" method="post" enctype="multipart/form-data">
    <label for="file">A文件:</label>
    <input type="file" name="file" id="file" />
    <br />
    <input type="submit" name="submit" value="提交查看结果" />
Beispiel #3
0
function str_split_any($str, $encode = NULL)
{
    empty($encode) && ($encode = mb_detect_encoding($str, 'ASCII,UTF-8,UCS-2,UCS-4,UTF-16,UTF-32'));
    $result = array();
    $encode = encoding_aliases($encode);
    switch ($encode) {
        case 'UTF-8':
        case 'UTF-8-Mobile#DOCOMO':
        case 'UTF-8-Mobile#KDDI-A':
        case 'UTF-8-Mobile#KDDI-B':
        case 'UTF-8-Mobile#SOFTBANK':
            $result = str_split_utf8($str);
            break;
        case 'UTF-16':
        case 'UTF-16LE':
        case 'UTF-16BE':
        case 'UCS-2':
        case 'UCS-2LE':
        case 'UCS-2BE':
            $result = str_split_utf16($str);
            break;
        case 'UTF-32':
        case 'UTF-32LE':
        case 'UTF-32BE':
        case 'UCS-4':
        case 'UCS-4LE':
        case 'UCS-4BE':
            $result = str_split_utf32($str);
            break;
        case 'ASCII':
            //单字节
        //单字节
        case '8bit':
            //拉丁文区
        //拉丁文区
        case 'ISO-8859-1':
        case 'ISO-8859-2':
        case 'ISO-8859-3':
        case 'ISO-8859-4':
        case 'ISO-8859-5':
        case 'ISO-8859-6':
        case 'ISO-8859-7':
        case 'ISO-8859-8':
        case 'ISO-8859-9':
        case 'ISO-8859-10':
        case 'ISO-8859-13':
        case 'ISO-8859-14':
        case 'ISO-8859-15':
        case 'ISO-8859-16':
        case 'Windows-1251':
        case 'Windows-1252':
        case 'Windows-1254':
        case 'CP850':
        case 'CP866':
        case 'ArmSCII-8':
            //单字节区
        //单字节区
        case 'pass':
        case 'auto':
        case 'wchar':
        case 'byte2be':
        case 'byte2le':
        case 'byte4be':
        case 'byte4le':
        case 'BASE64':
        case 'UUENCODE':
        case 'HTML-ENTITIES':
        case 'Quoted-Printable':
        case '7bit':
            $result = str_split($str);
            break;
        default:
            $result = str_split_multibyte($str, $encode);
            break;
    }
    return $result;
}
 private function dividePatternStr($str)
 {
     $strArray1 = explode(" ", $str);
     foreach ($strArray1 as $str) {
         unset($strArray2);
         $strArray2 = str_split_utf8($str);
         $resultStr = implode("[^,]*", $strArray2);
         $result[] = "/,[^,]*" . $resultStr . "[^,]*,/i";
     }
     return $result;
 }