i am having problems with a function that is supposed to return all the childern of a certian object and encode the whole thing into JSON. Currently it is working but there are a bunch of nulls in the JSON encode and i have tried array_filter()
and a foreach
loop to scrub them out, both didn't work.
findChildren($conn, $topic);
$data = array();
function findChildren($conn, $topic) {
$rst = $conn->query("SELECT topicID, topicTitle, topicParentID, topicDeleted FROM tbl_topics WHERE topicParentID = $topic");
while ($row = $rst->fetch_assoc()) {
if ($row['topicDeleted'] == 0) {
//$data[] = htmlentities($row, UTF-8);
if($row != '') {
$data[] = $row;
}
findChildren($conn, $row['topicID']);
}
}
echo json_encode( $data );
}
any help would be awesome. Thanks.