コード例 #1
0
 */
require_once 'Encoding.php';
$db = new DBNaryInterface();
$encode = new Encoding();
$db->setLanguageFrom('french');
$db->setLanguageTo('english');
$db->connect();
$words = extractLinesFromFile('dicos/dico_295065.txt');
foreach ($words as $word) {
    $word = $encode->toUTF8(trim($word));
    $word = getFirstWord(trim($word));
    $db->getTranslations(trim($word));
    $availableTranslations = $db->getResultInList();
    if (!empty($availableTranslations)) {
        foreach ($availableTranslations as $translation) {
            writeInFile('dico_from_dbnary.txt', trim($word) . ' @ ' . trim($translation) . chr(10));
        }
    }
}
/* * ***********************
 *      FUNCTIONS
 * *********************** */
/**
 * Return the first token of a string.
 * @param   string  $text   Text.
 * @return  string  Token.
 */
function getFirstWord($text)
{
    $words = explode(chr(9), $text);
    return $words[0];
コード例 #2
0
ファイル: controller.php プロジェクト: echmaster/data
<?php

require_once "model.php";
if (isset($_POST["set"]) && isset($_POST["answer"])) {
    $result = readAr("answer.txt");
    writeInFile($result, "answer.txt");
}
require_once "view.html";