Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function patchBook()
- {
- $all = fopen("district.txt","r");
- $div_cmp = "Division" ;
- $d_cmp = "District" ;
- $t_cmp = "Upazila" ;
- while(!feof($all))
- {
- $line = fgets($all);
- $div = "";
- $dist = "" ;
- $thana = "" ;
- $temp = "" ;
- $id_value = 0 ;
- for($i=0 ; $i<strlen($line) ; $i++)
- {
- if($line[$i] !== ' ') {
- // if($id_value == 2)
- // echo $line[$i];
- $temp .= $line[$i];
- }
- else {
- if ($id_value == 0) {
- if($div_cmp === $temp)
- {
- echo $div ;
- echo " <--> ";
- $id_value++;
- }
- else if(strlen($temp)>0) {
- $div .= $temp;
- $div .= " ";
- }
- }
- else if($id_value == 1)
- {
- if($d_cmp === $temp)
- {
- echo $dist ;
- echo " <--> ";
- $id_value++;
- }
- else if(strlen($temp)>0) {
- $dist .= $temp;
- $dist .= " ";
- }
- }
- else if($id_value == 2)
- {
- // if($t_cmp === $temp)
- // {
- // echo $thana ;
- // echo " <--> ";
- // $id_value++;
- // }
- if(strlen($temp) > 0) {
- $thana .= $temp;
- $thana .= " " ;
- }
- }
- $temp = "" ;
- }
- }
- $district = new district;
- $district->district = $dist ;
- $district->upazila = $thana ;
- $district->save();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement