Merhaba resimde isaretlediyim seyleri nasil degisken formasinda alirim?
http://prntscr.com/lrkk7x
Bu txt dosyasini nasil degisken formasinda alirim? |
8 Mesajlar | 1.866 Okunma |
$file_handle = fopen("./heyvan.txt", "r");
$content = fread($file_handle, filesize("./heyvan.txt"));
$questions = explode("\n\n", $content);
$allQuestions = [];
foreach ($questions as $question) {
$question .= "@end";
$singleQuestion = [];
$q_regex = createRegex("","?");
preg_match($q_regex, $question,$match);
$singleQuestion["question"] = $match[0];
$q_regex = createRegex("A)","B)");
preg_match($q_regex, $question,$match);
$singleQuestion["a"] = $match[1];
$q_regex = createRegex("B)","C)");
preg_match($q_regex, $question,$match);
$singleQuestion["b"] = $match[1];
$q_regex = createRegex("C)","D)");
preg_match($q_regex, $question,$match);
$singleQuestion["c"] = $match[1];
$q_regex = createRegex("D)","E)");
preg_match($q_regex, $question,$match);
$singleQuestion["d"] = $match[1];
$q_regex = createRegex("E)","@end");
preg_match($q_regex, $question,$match);
$singleQuestion["e"] = $match[1];
$singleQuestion = array_map(function($item){ return trim($item);}, $singleQuestion);
array_push($allQuestions,$singleQuestion);
}
fclose($file_handle);
var_dump($allQuestions);
function createRegex($start, $end)
{
$delimiter = '#';
return $delimiter . preg_quote($start, $delimiter)
. '(.*?)' . preg_quote($end, $delimiter)
. $delimiter . 's';
}
?>
$file_handle = fopen("./heyvan.txt", "r");
$content = fread($file_handle, filesize("./heyvan.txt"));
$questions = explode("\n\n", $content);
$allQuestions = [];
foreach ($questions as $question) {
$question .= "@end";
$singleQuestion = [];
$q_regex = createRegex("","?");
preg_match($q_regex, $question,$match);
$singleQuestion["question"] = $match[0];
$q_regex = createRegex("A)","B)");
preg_match($q_regex, $question,$match);
$singleQuestion["a"] = $match[1];
$q_regex = createRegex("B)","C)");
preg_match($q_regex, $question,$match);
$singleQuestion["b"] = $match[1];
$q_regex = createRegex("C)","D)");
preg_match($q_regex, $question,$match);
$singleQuestion["c"] = $match[1];
$q_regex = createRegex("D)","E)");
preg_match($q_regex, $question,$match);
$singleQuestion["d"] = $match[1];
$q_regex = createRegex("E)","@end");
preg_match($q_regex, $question,$match);
$singleQuestion["e"] = $match[1];
$singleQuestion = array_map(function($item){ return trim($item);}, $singleQuestion);
array_push($allQuestions,$singleQuestion);
}
fclose($file_handle);
var_dump($allQuestions);
function createRegex($start, $end)
{
$delimiter = '#';
return $delimiter . preg_quote($start, $delimiter)
. '(.*?)' . preg_quote($end, $delimiter)
. $delimiter . 's';
}
?>