Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. public function patchBook()
  2. {
  3. $all = fopen("district.txt","r");
  4. $div_cmp = "Division" ;
  5. $d_cmp = "District" ;
  6. $t_cmp = "Upazila" ;
  7.  
  8. while(!feof($all))
  9. {
  10. $line = fgets($all);
  11. $div = "";
  12. $dist = "" ;
  13. $thana = "" ;
  14. $temp = "" ;
  15. $id_value = 0 ;
  16.  
  17. for($i=0 ; $i<strlen($line) ; $i++)
  18. {
  19. if($line[$i] !== ' ') {
  20. // if($id_value == 2)
  21. // echo $line[$i];
  22.  
  23. $temp .= $line[$i];
  24. }
  25.  
  26. else {
  27. if ($id_value == 0) {
  28. if($div_cmp === $temp)
  29. {
  30. echo $div ;
  31. echo " <--> ";
  32. $id_value++;
  33. }
  34.  
  35. else if(strlen($temp)>0) {
  36. $div .= $temp;
  37. $div .= " ";
  38. }
  39. }
  40.  
  41. else if($id_value == 1)
  42. {
  43. if($d_cmp === $temp)
  44. {
  45. echo $dist ;
  46. echo " <--> ";
  47. $id_value++;
  48. }
  49.  
  50. else if(strlen($temp)>0) {
  51. $dist .= $temp;
  52. $dist .= " ";
  53. }
  54. }
  55.  
  56. else if($id_value == 2)
  57. {
  58. // if($t_cmp === $temp)
  59. // {
  60. // echo $thana ;
  61. // echo " <--> ";
  62. // $id_value++;
  63. // }
  64.  
  65. if(strlen($temp) > 0) {
  66. $thana .= $temp;
  67. $thana .= " " ;
  68. }
  69. }
  70.  
  71. $temp = "" ;
  72. }
  73. }
  74.  
  75. $district = new district;
  76. $district->district = $dist ;
  77. $district->upazila = $thana ;
  78. $district->save();
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement