本文整理汇总了PHP中Files::fileToArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Files::fileToArray方法的具体用法?PHP Files::fileToArray怎么用?PHP Files::fileToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Files
的用法示例。
在下文中一共展示了Files::fileToArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: webpageTextChecker
public function webpageTextChecker()
{
$this->deleteOldFiles();
$site = Files::fileToArray('sites.txt')[0];
Curl::cookieCreation($site);
$pageNumber = -1;
$pages = self::clearPages();
$pagesUnique = array_unique($pages);
foreach ($pagesUnique as $page) {
self::setTextForSearch($page);
/* check if page does not start with
slash then add it */
if ($page[0] !== "/") {
if (in_array("/{$page}", $pages)) {
continue;
}
$page = "/{$page}";
}
$textForSearch = self::getTextForSearch();
$pageNumber++;
$sitePage = $site . $page;
echo count($pagesUnique) - $pageNumber . ".", $sitePage . "\n";
$this->pageTextChecker($page, $pages, $site, $sitePage, $textForSearch);
}
$logFileName = 'ptc_log_';
$log = $this->getLog();
LogCreation::logFileCreator($log, $logFileName);
}
示例2: array
<?php
require_once '../helpers/Helpers.php';
use helpers\Helpers;
$dbLog = Files::csvToArray('logged_time.csv');
$heroLabels = Files::fileToArray('hero_labels.txt');
$groupByPerson = array();
//group by person and sum log
foreach ($dbLog as $dbLogRow) {
if (!array_key_exists($dbLogRow[1], $groupByPerson)) {
$item = ['name' => $dbLogRow[1], 'time' => $dbLogRow[2]];
$groupByPerson[$dbLogRow[1]] = $item;
} else {
$groupByPerson[$dbLogRow[1]]['time'] += $dbLogRow[2];
}
}
//add percent to log from database
$dbLogPercent = $dbLog;
foreach ($dbLogPercent as &$dbLogPercRow) {
foreach ($groupByPerson as $groupByPersonRow) {
if ($dbLogPercRow[1] == $groupByPersonRow['name']) {
$dbLogPercRow['%'] = round($dbLogPercRow[2] * 100 / $groupByPersonRow['time'], 2) . '%';
} elseif (!in_array($dbLogPercRow[0], $heroLabels)) {
$dbLogPercRow[0] = 'Else';
}
}
}
unset($dbLogPercRow);
//create array with people from dbLog
$people = array();
foreach ($dbLogPercent as $dbLogPercKey => $dbLogPercRow) {
示例3: websiteTextChecker
public function websiteTextChecker()
{
self::deleteOldFiles();
$sites = Files::fileToArray('sites.txt');
$pagesFromFile = Files::fileToArray('pages.txt');
$siteNumber = -1;
$textForSearch = Files::fileToArray('text_for_search.txt');
foreach ($sites as $site) {
$site = InputInfoValidator::siteNameValidator($site);
if (!is_null(GetAllHrefs::getOptsForPages())) {
options:
GetAllHrefs::setOptsForPages();
}
if (in_array(GetAllHrefs::getOptsForPages(), array(1, 3))) {
if (!isset($checkBlog)) {
$checkBlog = GetAllHrefs::setCheckBlog();
}
Curl::cookieCreation($site);
$sitePage = $site;
$curlForLinks = Curl::getCurlResult($sitePage)[0];
$pages = GetAllHrefs::getHrefs($site, $curlForLinks);
if (GetAllHrefs::getOptsForPages() == 3) {
$pagesCurl = $pages;
$pages = array_merge($pagesCurl, $pagesFromFile);
}
} elseif (GetAllHrefs::getOptsForPages() == 2) {
Curl::cookieCreation($site);
$pages = $pagesFromFile;
} else {
goto options;
}
$pageNumber = -1;
$siteNumber++;
foreach ($pages as $key => &$page) {
$pageNumber++;
if (strpos($page, $site) == TRUE) {
$sitePage = $page;
} else {
/* check if page does not start with
slash then add it */
if ($page[0] !== "/") {
if (in_array("/{$page}", $pages)) {
continue;
}
$page = "/{$page}";
}
$sitePage = "{$site}{$page}";
}
#counter for pages, which are being checker
echo count($sites) - $siteNumber . ".", count($pages) - $pageNumber . ".", $sitePage . "\n";
self::pageTextChecker($page, $pages, $site, $sitePage, $textForSearch);
}
}
$logFileName = 'wtc_log_';
$log = $this->log;
LogCreation::logFileCreator($log, $logFileName);
}