about summary refs log tree commit diff
path: root/sourcecodes/mat_structure.php
diff options
context:
space:
mode:
authorziejd22017-09-14 15:39:41 -0500
committerziejd22017-09-14 15:57:50 -0500
commitc4f926438dcb8abe805e910399940f79ff643c4b (patch)
tree3146d05ada5cf4b48d9bdd16c1baa498e8df7192 /sourcecodes/mat_structure.php
parent57ebf49403b75dcf8482d174b59f7fd2a961d98e (diff)
downloadBNW-c4f926438dcb8abe805e910399940f79ff643c4b.tar.gz
Add files via upload
Diffstat (limited to 'sourcecodes/mat_structure.php')
-rw-r--r--sourcecodes/mat_structure.php78
1 files changed, 78 insertions, 0 deletions
diff --git a/sourcecodes/mat_structure.php b/sourcecodes/mat_structure.php
new file mode 100644
index 00000000..dd1daccf
--- /dev/null
+++ b/sourcecodes/mat_structure.php
@@ -0,0 +1,78 @@
+<?php
+function structure_change($keyval)
+{
+$dir="./data/";
+$matfile=$dir.$keyval."varname.txt";
+$namelist=file_get_contents("$matfile");
+$matfilestruct=$dir.$keyval."structure_input.txt";
+$list=file_get_contents("$matfilestruct");
+$ft=$dir.$keyval."structure_input_new.txt";
+$fp = fopen("$ft","w");
+
+$str_arrname=array();
+$str_arrname=explode("\n",$namelist);
+$dataname=array();
+$dataname=explode("\t",$str_arrname[0]);
+
+$arrname=array();
+$arrname=explode("\n",$list); 
+
+
+$cell_val=array();
+
+$data_cell=array();
+
+$name=explode("\t",$arrname[0]);
+
+
+
+$i=0;
+foreach($name as $name_cell)
+{
+ $cell_val[$i]=1;
+ $name_cell=trim($name_cell);
+  foreach($dataname as $list_name)
+  { 
+       $list_name=trim($list_name);
+        if($name_cell==$list_name)
+        {   
+             //echo $name_cell; 
+             $cell_val[$i]=0;
+             
+        }
+   
+  }
+$i++;
+}
+
+
+$j=0;
+for($l=0;$l<=$i;$l++)
+{
+  $line=$arrname[$l];
+
+  if($j==0)
+  {
+    fwrite($fp,$line);
+    
+  }
+  else
+  {  
+   
+    $data_cell=explode("\t",$line);
+  
+    for($k=0;$k<$i;$k++)
+    {
+       $cell=$data_cell[$k]*$cell_val[$k];
+       fprintf($fp,"%s\t",$cell);
+    } 
+  }
+  fprintf($fp,"\n");
+ 
+  $j++;
+}
+
+//return $matfilestruct;
+}
+
+?>
\ No newline at end of file