I want to convert this array that Array[4] should not give null it can give blank space (empty string).
Array (
[0] => 1
[1] => 4
[2] => 0
[3] => V
[4] =>
[5] => N
);
(The reason for the change, unrelated to the general question)
Fatal error: Uncaught exception
'PDOException' with message 'Database
error [23000]: Column 'message' cannot
be null, driver error code is 1048' in
Use this function. This will replace null to empty string in nested array also
Output will be :
Try online here : https://3v4l.org/7uXTL
There is even better/shorter/simpler solution. Compilation of already given answers. For initial data
with
$result will be
This should work even in php4 :)
You can use this instead.
PHP 5.3+
This will map the array to a new array that utilizes the null ternary operator to either include an original value of the array, or an empty string if that value is null.