我有一些json格式的.txt文件。我试图逐个获取每个文件,修改它的内容,然后将这些内容放回到文件中。为此,我已经执行了一个循环,为每个文件执行此过程。循环在第一次迭代中运行绝对正常,但在第二次迭代中它会抛出一个警告:
“警告:file_get_contents(../ videos / list2.txt)[function.file-get-contents]:无法打开流:第85行的D:\ wamp \ www \ dtt_admin_V2 \ pages \ jason2.php中的参数无效” 。
file_get_contents(../videos/list2.txt)中的论点是正确的。它没有问题。我不能导致这个错误的原因。有关此错误的任何帮助都非常有用。带有错误的行在下面的代码块中用/ * line(#)* /等注释突出显示。
$sql = "SELECT * FROM dtt_location";
$result = $conn->query($sql);
if ($result->num_rows > 0)
{
while($row = $result->fetch_assoc()){
$path_text=$row['path_text'];
//echo "id_for_location".$id_for_location."
";
$file = $path_text;
/*line48 */ $text = file_get_contents($file);
//echo $text."
";
$someObject = json_decode($text);
$array_object=objectToArray($someObject);
$ar_size=sizeof($array_object);
$count=0;
$array_name[]="";
$array_url[]="";
$skip=0;
while($count
$temp_element=$array_object[$count];
//print_r($temp_element);
if($temp_element["name"]!=$video_name){
$array_name[$skip]=$temp_element["name"];
$array_url[$skip]=$temp_element["url"];
//$b=$a[0];
$skip++;
}
else{
//echo $count."
"."temp"."
".$temp_element["name"]."
".$temp_element["url"]."
";
//echo $count."
"."selected"."
".$video_name."
".$path_video."
";
}
$count++;
}
$count=0;
$ar_si=$ar_size-1;
//echo $ar_size."
";
//echo $ar_si;
$create[]="";
while($count
{
echo $count;
$create[$count]=$first.$array_name[$count]. $second.$array_url[$count].$third;
$count++;
}
$create_j=join(",",$create);
$create_j="[".$create_j."]";
if($create_j=="[]"){
//echo "$create_j"."
";
$create_j=$text;
//echo "$create_j";
//error_msg_empty_broadcast();
/*Line 108 */ file_put_contents($file, $create_j);
}//echo $create_j."
";
else
{
file_put_contents($file, $create_j);
}
}