Replacing empty string with nulls in array php
I don't think there's such a function, so let's create a new one
$array = array( 'first' => '', 'second' => '');$array2 = array_map(function($value) { return $value === "" ? NULL : $value;}, $array); // array_map should walk through $array// or recursivefunction map($value) { if (is_array($value)) { return array_map("map", $value); } return $value === "" ? NULL : $value;};$array3 = array_map("map", $array);