$this->file = [
"pageURL": "\/?editComments",
"0": "",
"1": [
"1", "2", "3" //etc
]
//etc
]
foreach ($this->file as $k => $v) {
echo "$k - $v - ";
var_dump($this->file[$k]);
}
pageURL - /?editComments - string(1) "/"
0 - - NULL
1 - Array - NULL
2 - Array - NULL
3 - Array - NULL
Strings containing valid decimal integers, unless the number is preceded by a + sign, will be cast to the integer type. E.g. the key "8" will actually be stored under 8. On the other hand "08" will not be cast, as it isn't a valid decimal integer.
foreach ($this->file as $k => $v) {
foreach ($this->file as $k => $v) {
echo "$k - $v - ";
var_dump($this->file[$k]);
}
if ($this->file = $v) {
}
$kff['file']['json'] = function ($d = NULL, $path = DATA_PATH, $rewrite = 0)
{
global $kff;
// var obj = is_array($d) || is_object($d);
if(!is_array($d) && !chkfile($path, 0, __FILE__ . ' : ' . __LINE__)) return [];
if(is_null($d))
{
# GET base
return (array) json_decode(@file_get_contents($path), true);
}
elseif(is_array($d))
{
# SET assert the results
// echo '$d = '; var_dump($d); echo '<br>';
// $db = !$rewrite ? array_replace($kff['file']['json'](NULL, $path), $d) : $d;
$db = !$rewrite ? array_merge($kff['file']['json'](NULL, $path), $d) : $d;
// echo '$db = '; var_dump($db); echo '<br>';
// echo '$path = '; var_dump($path); echo '<br>';
return file_put_contents($path, json_encode($db, JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK), LOCK_EX);
//
}
elseif(is_string($d))
{
# GET value
return $kff['file']['json'](NULL, $path)[$d];
}
else
{
die('$kff[\'sys\'][\'data\']' . " не может быть выполнена с аргументом $d");
}
};
//=======
$this->file = file_exists($this->path)? $kff['file']['json'](NULL, $this->path) : [];
//=======
foreach ($this->file as $k => $v) {
echo "$k - $v - ";
// var_dump($v);
var_dump($this->file[$k]);
}
/?editComments - string(1) "/"
0 - - NULL
1 - Array - NULL
2 - Array - NULL
3 - Array - NULL