如何解决将元素添加到数组,删除文件并使用新数组更新它 - PHP
这真的很奇怪...
我有一个带有空数组的 php 文件 (B.php)。 我将文件 (B.php) 包含在 A.php 文件中,并向数组中添加一个元素。
我删除了 B.php 文件并创建了一个具有相同路径的新文件,但插入到新的更新数组中。
操作有效,但如果我在里面打开新的 B.php,我只能找到元素。为什么?
option = {
title: {
text: '基础雷达图'
},legend: {
data: ['预算分配(Allocated Budget)','实际开销(Actual Spending)']
},radar: {
// shape: 'circle',indicator: [
{ name: '销售(Sales)',max: 6500},{ name: '管理(Administration)',max: 16000},{ name: '信息技术(Information Technology)',max: 30000},{ name: '客服(Customer Support)',max: 38000},{ name: '研发(Development)',max: 52000},{ name: '市场(Marketing)',max: 25000}
]
},tooltip: {},series: [{
name: '预算 vs 开销(Budget vs spending)',type: 'radar',data: [
{
value: [4200,3000,20000,35000,50000,18000],name: '预算分配(Allocated Budget)'
},{
value: [5000,14000,28000,26000,42000,21000],name: '实际开销(Actual Spending)'
}
],tooltip:{
// do something here if you want
}
}]
新数组应该是:
include("B.php"); //includo il file con gli id delle offerte
$array[]= '2cbe9'; //add element
foreach (glob("folder/B.php") as $old){
unlink($old);
//create new file
file_put_contents("folder/B.php",$array);
}
print_r($array);
但是当我打开新文件(B.php)时,我只有这个:
$array = array("2cbe9");
//this is result of print_r
Array ( [0] => "2cbe9")
没有php标签,变量名。没有,只有元素。
为什么?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。