[Solved] put blank value instead of null in array value php [duplicate]


PHP Code (modified from Replacing empty string with nulls in array php):

$array = array(
   'first' => NULL,
   'second' => NULL
);

echo json_encode($array);

$array2 = array_map(function($value) {
   return $value === NULL ? "" : $value;
}, $array); // array_map should walk through $array

echo json_encode($array2);

Output:

{"first":null,"second":null}

{"first":"","second":""}

1

solved put blank value instead of null in array value php [duplicate]