Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- * Description of ProgramJAO
- *
- * @author student
- */
- class ProgramJAO {
- //put your code here
- public $wynik;
- public function main() {
- $zbiory = array(); // 1.0
- $zbior = array(); // 2.0
- $plik = fopen('dane.txt', 'r'); // 3.0
- if(FALSE == $plik){
- throw new Exception('Bład przy otwierania pliku');
- }
- $znaki = array(" ", "\t", "\r", "\n");
- $noweZnaki = "";
- $i = 0;
- while(feof($plik) == FALSE){
- $linia = fgets($plik, 4096);
- if(FALSE == $linia){
- break;
- }
- $linia = str_replace($znaki, $noweZnaki, $linia);
- $pierwszyZnak = substr($linia, 0, 1);
- if ($pierwszyZnak != "{") {
- break;
- }
- $ostatniZnak = substr($linia, -1);
- if ($ostatniZnak != "}") {
- break;
- }
- $linia = ltrim($linia, "{");
- $linia = rtrim($linia, "}");
- $zbior = explode(",", $linia);
- $zbiory[$i] = $zbior;
- $i = $i +1;
- }
- fclose($plik);
- $this -> wynik = $zbiory;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement