Skip to content

Instantly share code, notes, and snippets.

@justinkelly
Created July 3, 2011 10:26
Show Gist options
  • Save justinkelly/1062130 to your computer and use it in GitHub Desktop.
Save justinkelly/1062130 to your computer and use it in GitHub Desktop.
PHP function to strip null array entries
<?php
/*
* use this function to strip null array entries from an array
* useful when doing a db update with pdo/zend_db_table etc..
*/
function strip_null_array_entries($values){
$array = array();
foreach($values as $key=>$value){
if( ($value!=='') AND (!is_null($value)) ) $array[$key] = $value;
}
return $array;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment