I have a json array storred in a file looking like:
["bla bla","bla bla2","bla bla3"]
And if I want to remove one of these objects from the json array with the code below the json converts to another type of array looking like:
{"1":"bla bla","2":"bla bla2","3":"bla bla3"}
I dont want this to happen because it screws up code in another place. How can I achieve this?
$eng = json_decode($en_banners, false);
unset($eng[$id]);
$myFile = "languages/banners.php";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "<?php \$de_banners='".json_encode($eng)
JavaScript arrays are zero-based so there’s no possible way to create a JavaScript array from a PHP array with gaps unless you fill the gaps:
If array keys are not relevant, you can simply ignore them:
If none of these solutions apply, we need more data 🙂