Skip to content

Instantly share code, notes, and snippets.

@Trainmaster
Created April 14, 2014 10:50
Show Gist options
  • Save Trainmaster/10637229 to your computer and use it in GitHub Desktop.
Save Trainmaster/10637229 to your computer and use it in GitHub Desktop.
<?php
$data = array('foo', '', 'bar');
array_walk_recursive($data, function (&$value, $key) {
if ($value === '') {
$value = null;
}
});
var_dump($data);
// array(3) { [0]=> string(3) "foo" [1]=> NULL [2]=> string(3) "bar" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment