我在Windows 10下运行Cygwin并尝试安装pyodbc时 我一直在寻找类似的问题多个小时,但找不到对我有用的东西。据我所知,有一些confilicting数据类型声明,但我不知道该怎么做 任何帮助将不胜感激。感谢任何花时间帮助我的人!
$cd=[]; // declare array
$trash=[];
$i=-1; // set outer index
$concat=true;
$file=fopen('inventory.txt','r');
while(!feof($file)){
$row=trim(fgets($file,1024));
if(preg_match('/^\(Cd\)\s(.+)/',$row,$match)){ // capture Cd numbers
++$i; // increment outer_index
$j=-1; // reset inner_index
$id=$match[1]; // store cd value
$concat=true;
$row_previous=false;
$row_ob=false;
}elseif(preg_match('/^(\(..\)\s.*)/',$row,$match)){ // capture Cd data
++$j; // this is a new innerarray element, increment its index
$cd[$i][$id][$j]=$match[1]; // push element into array
//$concat=(strpos($match[1],'(Co)')!==0?true:false);
If (substr($row, 0, 5) == '(Co) ') {
$row_previous=true;
}
}elseif(isset($id)){ // ignore all file header content
If (($row_previous == true)and ($row_ob !== true)){
++$j; //increment its index to insert variable value created for the additional lines
$row="(Ob) ". (trim($row)); //create pre value variable
$row_ob=true;
$cd[$i][$id][$j].="$row "; // concatenate to last element to new
}else{
$cd[$i][$id][$j].=" $row"; // concatenate to last element
}
}
}
echo "<pre>";
var_export($cd); // display in true nested form
echo "</pre>";
foreach($cd as $outer_index=>$cdarrays){
foreach($cdarrays as $id=>$innerarrays){
foreach($innerarrays as $inner_index=>$line){
echo "$outer_index : $id : $inner_index = $line<br>"; // display keys & values by row
}
}
}