I am pulling tables from a database and I'm trying to keep the userdata table from being included in the array that is eventually sent to my application. I've tried using array_diff and unset, but I haven't had any luck with it. As tables can be added, the userdata one won't always be in the same position.
The array when I check on JSONlint.com appears like this:
[{"table_name": "OSA"
}, {
"table_name": "OSB"
}, {
"table_name": "userdata"
}]
code in PHP file:
$tables = array();
while ($row = mysqli_fetch_array($result)){
array_push($tables, array("table_name"=>$row[0]));
}
$remove= array({"table_name": "userdata"});
$result = array_diff($tables, $remove);
echo json_encode($result);
table_namekey.$remove= array(array("table_name" => "userdata"));