I am working in PHP and have an issue with json_encode()
. The process wipes the inital "key" that was set by the "array_values" command as shown below.
array(1) {
[0]=> array(5) {
["ID"]=> string(4) "2679" [
"PackageName"]=> "Update for Windows 8.1 for x64-based Systems (KB2965065)"
["Description"]=> string(262) "Install this update to resolve issues in Windows."
["KB"]=> string(7) "2965065"
["Repo"]=> string(21) "Windows Update Server"
}
$packages = array_values($this->control->fetchPackageTables($this->input->get("platform")));
[
{
"ID":"2679",
"PackageName":"Update for Windows 8.1 for x64-based Systems (KB2965065)",
"Description":"Install this update to resolve issues in Windows.",
"KB":"2965065",
"Repo":"Windows Update Server"
}
]
I have tried looping with a foreach through the array and setting a number but it still gets dropped. Any ideas?
Thanks!
json_encode()
.array_values
is to strip off the keys and return a numbered array[]
is an array in JSON. Arrays are numeric, and automatically start at 0.