I have a JSON file like this one:
[
{
"NAME": "Algo",
"ALIAS": "Algo"
},
{
"NAME": "Otro",
"ALIAS": "Otra cosa"
}
]
I need to delete the second element with the index number already (there are many more elements (urls)). How I do this?
I manually tried unset($this->db[1])
but it did not work.
Code used
$this->db = json_decode(file_get_contents(self::DB_PATH), true);
$index_num = 0;
foreach($this->db as $url) {
$index_num++;
if($url['ALIAS'] == $this->alias) {
unset($url[$index_num]);
}
}
Thanks for your answers.