ver.0.2
This commit is contained in:
parent
5b3ea91ac5
commit
5468b1d286
@ -7,8 +7,3 @@
|
||||
Зайцев;Федор;Александрович;2014-12-22;Мужчина;+7;6667774441;asert@mail.ru
|
||||
Иванов;Петр;Михайлович;2002-03-11;Мужчина;+7;1111111111;asert@mail.ru
|
||||
Иванов;Роман;Сергеевич;2002-03-11;Мужчина;+7;1111111111;ple.anastasiya@gmail.com
|
||||
Билай;Станислав;Романович;4444-04-04;Мужчина;+7;9493761924;stasbilay02@yandex.ru
|
||||
Билай;Станислав;Романович;4444-04-04;Мужчина;+7;9493761924;stasbilay02@yandex.ru
|
||||
Билай;Станислав;Романович;4444-04-04;Мужчина;+7;9493761924;stasbilay02@yandex.ru
|
||||
Билай;Станислав;Романович;4444-04-04;Мужчина;+7;9493761924;stasbilay02@yandex.ru
|
||||
Билай;Станислав;Романович;4444-04-04;Мужчина;+7;9493761924;stasbilay02@yandex.ru
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
function search(string $strFromFile, string $strForSearch): ?string
|
||||
function search(string $strForSearch, string $strFromFile): ?string
|
||||
{
|
||||
if($strFromFile) {
|
||||
if (preg_match($strForSearch, $strFromFile))
|
||||
|
6
form.php
6
form.php
@ -29,3 +29,9 @@
|
||||
<input type="reset">
|
||||
</form>';
|
||||
echo $form;
|
||||
|
||||
/* $formSearch =
|
||||
'<form action="info.php" target="_blank" method="post">
|
||||
<input type="search" name="result_search"> <br> <br>
|
||||
<input type="submit" value="Поиск">
|
||||
</form>';*/
|
22
info.php
22
info.php
@ -5,7 +5,7 @@ namespace src;
|
||||
use Information;
|
||||
|
||||
require_once "src/Information.php";
|
||||
require_once "Search.php";
|
||||
/*require_once "Search.php";*/
|
||||
|
||||
$fileName = "Information.txt";
|
||||
$fileModeOpen = "a";
|
||||
@ -21,15 +21,29 @@ $file = fopen($fileName, $fileModeOpen);
|
||||
fwrite($file, $string);
|
||||
fclose($file);
|
||||
|
||||
$file = fopen($fileName, "r");
|
||||
$formSearch =
|
||||
'<form action="search_result.php" target="_blank" method="post">
|
||||
<input type="search" name="result_search"> <br> <br>
|
||||
<input type="submit" value="Поиск">
|
||||
</form>';
|
||||
|
||||
echo $formSearch;
|
||||
|
||||
/*$file = fopen($fileName, "r");
|
||||
|
||||
$arrKey = array('surname', 'name', 'patronymic', 'dateOfBirth', 'gender', 'countryCode', 'phoneNumber', 'email');
|
||||
|
||||
$parsingArray = array();
|
||||
|
||||
echo "<pre>";
|
||||
print_r($_REQUEST);
|
||||
|
||||
$forSearch = $_REQUEST['result_search'];
|
||||
|
||||
while (!feof($file)) {
|
||||
$str = fgets($file);
|
||||
if(search($str, '/\b(иванов)\b/ui')){
|
||||
//if(search($str, '/\b(иванов)\b/ui')){
|
||||
if(search($str, $forSearch)){
|
||||
$array = array_combine($arrKey, explode(";", $str));
|
||||
$obj = new Information();
|
||||
$obj->load($array);
|
||||
@ -37,6 +51,6 @@ while (!feof($file)) {
|
||||
}
|
||||
}
|
||||
echo "<pre>";
|
||||
print_r($parsingArray);
|
||||
print_r($parsingArray);*/
|
||||
|
||||
require "table.php";
|
36
search_result.php
Normal file
36
search_result.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace src;
|
||||
|
||||
use Information;
|
||||
|
||||
require_once "src/Information.php";
|
||||
require_once "Search.php";
|
||||
|
||||
$fileName = "Information.txt";
|
||||
|
||||
$file = fopen($fileName, "r");
|
||||
|
||||
$arrKey = array('surname', 'name', 'patronymic', 'dateOfBirth', 'gender', 'countryCode', 'phoneNumber', 'email');
|
||||
|
||||
$parsingArray = array();
|
||||
|
||||
echo "<pre>";
|
||||
print_r($_REQUEST);
|
||||
|
||||
$forSearch = '/\b(' . $_REQUEST['result_search'] . ')\b/ui';
|
||||
|
||||
while (!feof($file)) {
|
||||
$str = fgets($file);
|
||||
if(search($forSearch, $str)){
|
||||
//if(search($str, $forSearch)){
|
||||
$array = array_combine($arrKey, explode(";", $str));
|
||||
/* echo "<pre>";
|
||||
print_r($array);*/
|
||||
$obj = new Information();
|
||||
$obj->load($array);
|
||||
$parsingArray[] = $obj;
|
||||
}
|
||||
}
|
||||
|
||||
echo "<pre>";
|
||||
print_r($parsingArray);
|
Loading…
Reference in New Issue
Block a user