Skip to content

Commit

Permalink
Add helpful filter functions
Browse files Browse the repository at this point in the history
  • Loading branch information
sc0ttkclark committed Aug 19, 2024
1 parent 76caf18 commit fea6f2d
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions includes/data.php
Original file line number Diff line number Diff line change
Expand Up @@ -2643,6 +2643,42 @@ function pods_is_falsey( $value ) {
return isset( $supported_strings[ $value ] );
}

/**
* Filter out the nulls from the array of data.
*
* @since TBD
*
* @param array $data The array of data to filter.
*
* @return array The array with nulls filtered out.
*/
function pods_array_filter_null( array $data ): array {
return array_filter(
$data,
static function( $value ) {
return null !== $value;
}
);
}

/**
* Filter out the nulls and empty strings from the array of data.
*
* @since TBD
*
* @param array $data The array of data to filter.
*
* @return array The array with nulls and empty strings filtered out.
*/
function pods_array_filter_null_and_empty_string( array $data ): array {
return array_filter(
$data,
static function( $value ) {
return null !== $value && '' !== $value;
}
);
}

/**
* Make replacements to a string using key=>value pairs.
*
Expand Down

0 comments on commit fea6f2d

Please sign in to comment.