当前位置: 首页>>代码示例>>PHP>>正文


PHP readString函数代码示例

本文整理汇总了PHP中readString函数的典型用法代码示例。如果您正苦于以下问题:PHP readString函数的具体用法?PHP readString怎么用?PHP readString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了readString函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: takeInput

function takeInput()
{
    fscanf(STDIN, "%d", $cases);
    $stringArray = array();
    for ($i = 0; $i < $cases; $i++) {
        $stringArray[] = readString();
    }
    return $stringArray;
}
开发者ID:shikharsubedi,项目名称:spoj,代码行数:9,代码来源:palindromeUseString.php

示例2: decodeLength

function decodeLength($fd, $length, &$json, $level = 0)
{
    $pad = str_pad("", $level * 4, " ");
    $rest = 0;
    while ($rest + 5 < $length) {
        $type = readByte($fd);
        $nlen = readByte($fd);
        $dlen = readInt($fd, 4);
        $name = readString($fd, $nlen);
        $rest += 6 + $nlen + $dlen;
        if ($type == 1 || $type == 5) {
            $subj = array();
            decodeLength($fd, $dlen, $subj, $level + 1);
            if ($name == "") {
                $json[] = $subj;
            } else {
                $json[$name] = $subj;
            }
            //echo "$pad$type $nlen $dlen $name\n";
            continue;
        }
        if ($type == 2) {
            $number = readNumber($fd, $dlen);
            if ($name == "") {
                $json[] = $number;
            } else {
                $json[$name] = $number;
            }
            //echo "$pad$type $nlen $dlen $name => " . gmp_strval($number) . "\n";
            continue;
        }
        if ($type == 3) {
            $data = readString($fd, $dlen);
            if ($name == "") {
                $json[] = $data;
            } else {
                $json[$name] = $data;
            }
            //echo "$pad$type $nlen $dlen $name => $data\n";
            continue;
        }
        $data = readString($fd, $dlen);
        $dump = "";
        for ($inx = 0; $inx < strlen($data); $inx++) {
            $dump .= ord($data[$inx]) . " ";
        }
        echo "=========================={$type} {$nlen} {$dlen} {$name} {$dump}\n";
        exit(0);
    }
}
开发者ID:patrickz98,项目名称:xavaro,代码行数:50,代码来源:EPGDatabaseDump.php

示例3: search

function search($file, $word, &$statsList)
{
    $index = computeIndex($word);
    if ($index != -1) {
        fseek($file, $index * 4 + 4);
        // 4 bytes per entry, skip header
        $index = readInt($file);
        if ($index) {
            $start = sizeof($statsList);
            $count = $start;
            fseek($file, $index);
            $w = readString($file);
            while ($w) {
                $statIdx = readInt($file);
                if ($word == substr($w, 0, strlen($word))) {
                    // found word that matches (as substring)
                    $statsList[$count++] = array("word" => $word, "match" => $w, "index" => $statIdx, "full" => strlen($w) == strlen($word), "docs" => array());
                }
                $w = readString($file);
            }
            $totalHi = 0;
            $totalFreqHi = 0;
            $totalFreqLo = 0;
            for ($count = $start; $count < sizeof($statsList); $count++) {
                $statInfo =& $statsList[$count];
                $multiplier = 1;
                // whole word matches have a double weight
                if ($statInfo["full"]) {
                    $multiplier = 2;
                }
                fseek($file, $statInfo["index"]);
                $numDocs = readInt($file);
                $docInfo = array();
                // read docs info + occurrence frequency of the word
                for ($i = 0; $i < $numDocs; $i++) {
                    $idx = readInt($file);
                    $freq = readInt($file);
                    $docInfo[$i] = array("idx" => $idx, "freq" => $freq >> 1, "rank" => 0.0, "hi" => $freq & 1);
                    if ($freq & 1) {
                        $totalHi++;
                        $totalFreqHi += $freq * $multiplier;
                    } else {
                        $totalFreqLo += $freq * $multiplier;
                    }
                }
                // read name and url info for the doc
                for ($i = 0; $i < $numDocs; $i++) {
                    fseek($file, $docInfo[$i]["idx"]);
                    $docInfo[$i]["name"] = readString($file);
                    $docInfo[$i]["url"] = readString($file);
                }
                $statInfo["docs"] = $docInfo;
            }
            $totalFreq = ($totalHi + 1) * $totalFreqLo + $totalFreqHi;
            for ($count = $start; $count < sizeof($statsList); $count++) {
                $statInfo =& $statsList[$count];
                $multiplier = 1;
                // whole word matches have a double weight
                if ($statInfo["full"]) {
                    $multiplier = 2;
                }
                for ($i = 0; $i < sizeof($statInfo["docs"]); $i++) {
                    $docInfo =& $statInfo["docs"];
                    // compute frequency rank of the word in each doc
                    $freq = $docInfo[$i]["freq"];
                    if ($docInfo[$i]["hi"]) {
                        $statInfo["docs"][$i]["rank"] = (double) ($freq * $multiplier + $totalFreqLo) / $totalFreq;
                    } else {
                        $statInfo["docs"][$i]["rank"] = (double) ($freq * $multiplier) / $totalFreq;
                    }
                }
            }
        }
    }
    return $statsList;
}
开发者ID:ninghang,项目名称:bayesianPlay,代码行数:76,代码来源:search.php

示例4: search

function search($file, $word, &$statsList)
{
    $index = computeIndex($word);
    if ($index != -1) {
        fseek($file, $index * 4 + 4);
        // 4 bytes per entry, skip header
        $index = readInt($file);
        if ($index) {
            $start = sizeof($statsList);
            $count = $start;
            fseek($file, $index);
            $w = readString($file);
            while ($w) {
                $statIdx = readInt($file);
                if ($word == substr($w, 0, strlen($word))) {
                    // found word that matches (as substring)
                    $statsList[$count++] = array("word" => $word, "match" => $w, "index" => $statIdx, "full" => strlen($w) == strlen($word), "docs" => array());
                }
                $w = readString($file);
            }
            $totalFreq = 0;
            for ($count = $start; $count < sizeof($statsList); $count++) {
                $statInfo =& $statsList[$count];
                fseek($file, $statInfo["index"]);
                $numDocs = readInt($file);
                $docInfo = array();
                // read docs info + occurrence frequency of the word
                $totalFreq = 0;
                for ($i = 0; $i < $numDocs; $i++) {
                    $idx = readInt($file);
                    $freq = readInt($file);
                    $docInfo[$i] = array("idx" => $idx, "freq" => $freq, "rank" => 0.0);
                    $totalFreq += $freq;
                    if ($statInfo["full"]) {
                        $totalFreq += $freq;
                    }
                }
                // read name an url info for the doc
                for ($i = 0; $i < $numDocs; $i++) {
                    fseek($file, $docInfo[$i]["idx"]);
                    $docInfo[$i]["name"] = readString($file);
                    $docInfo[$i]["url"] = readString($file);
                }
                $statInfo["docs"] = $docInfo;
            }
            for ($count = $start; $count < sizeof($statsList); $count++) {
                $statInfo =& $statsList[$count];
                for ($i = 0; $i < sizeof($statInfo["docs"]); $i++) {
                    $docInfo =& $statInfo["docs"];
                    // compute frequency rank of the word in each doc
                    $statInfo["docs"][$i]["rank"] = (double) $docInfo[$i]["freq"] / $totalFreq;
                }
            }
        }
    }
    return $statsList;
}
开发者ID:rasata,项目名称:ifimsl,代码行数:57,代码来源:search.php

示例5: trackToFlash

function trackToFlash($id)
{
    if (file_exists("tracks/" . $id . ".track")) {
        $file = fopen("tracks/" . $id . ".track", "r");
        $startLine = false;
        $final = "";
        $lineid = 0;
        while (ftell($file) < filesize("tracks/" . $id . ".track")) {
            $skipIt = false;
            $length = readShort($file);
            if ($length == 0) {
                if (readByte($file) == 9) {
                    //End Array/Object
                    $skipIt = true;
                    if ($startLine == true) {
                        $startLine = false;
                    }
                } else {
                    skip($file, -1);
                    //Invalid item of length 0
                    $skipIt = true;
                }
            }
            if ($skipIt == false) {
                $name = readString($file, $length);
                $type = readByte($file);
                if ($type == 0) {
                    //Double
                    if ($startLine == true) {
                        $append = "s";
                    } else {
                        $append = "l";
                    }
                    if ($name != 'level') {
                        $val = readDouble($file);
                        if ((string) $val == 'NAN') {
                            $val = 'undefined';
                        }
                        $final .= $append . $lineid . "_" . $name . "=" . $val . "&";
                    } else {
                        skip($file, 8);
                    }
                }
                if ($type == 1) {
                    //Boolean (Show)
                    skip($file, 1);
                }
                if ($type == 2) {
                    //String
                    $strlength = readShort($file);
                    skip($file, $strlength);
                }
                //Type 3 & 6 Do Nothing
                if ($type == 8) {
                    //Array
                    if ($name == "startLine") {
                        $startLine = true;
                    } else {
                        $lineid = (int) $name;
                    }
                    skip($file, 4);
                }
            }
        }
        fclose($file);
        $final = substr($final, 0, strlen($final) - 1);
        return $final;
    }
}
开发者ID:TheWandererLee,项目名称:Git-Projects,代码行数:69,代码来源:functions.php

示例6: skip

                 $accelLines[$track]++;
             }
             if ($value == 2) {
                 $backLines[$track]++;
             }
         }
     }
 }
 if ($type == 1) {
     //Boolean (Show)
     skip($file, 1);
 }
 if ($type == 2) {
     //String
     $strlength = readShort($file);
     $value = readString($file, $strlength);
     $trackLengthOff[$currentTrack] = ftell($file) - $trackStartOff[$currentTrack] + 3;
     if ($name == 'label') {
         $trackName[$track] = $value;
         break;
     }
 }
 if ($type == 3) {
     //Object
     $currentTrack = (int) $name;
     $trackStartOff[$currentTrack] = ftell($file);
 }
 // Type 6: Undefined: Do Nothing
 if ($type == 8) {
     //Array
     if ($name == "startLine") {
开发者ID:TheWandererLee,项目名称:Git-Projects,代码行数:31,代码来源:analyze.php


注:本文中的readString函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。