I am having trouble trying to convert null values to empty strings with the results of my json_encode:
if ($uresult->num_rows >0) {
while($urow = $uresult->fetch_assoc()) {
$rresult = mysqli_query($con,"SELECT * FROM allid WHERE postid='$oldid' AND spaceid='$newid'");
$lrow = mysqli_fetch_assoc($rresult);
$tem = $lrow['postid'];
$ujson = json_encode($tem);
echo $ujson;
}
} else {
}
Here is the result of the $ujson:
"10"nullnullnullnull"25"
I looked up answers and I got this answer:
array_walk($tem,function(&$item){$item=strval($item);});
Doing this caused me to get this error:
Warning: array_walk() expects parameter 1 to be array, string given
Is this the correct way to convert a null to an empty string, if so, what am I doing wrong?
string given, it means$temis a string