Skip to content

Commit

Permalink
update str to uint array function
Browse files Browse the repository at this point in the history
  • Loading branch information
gardenboi committed Nov 26, 2023
1 parent e6c7bbf commit 948499f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions core/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,10 @@ function cf7a_maybe_split_mail_meta( $posted_data, $message_tag, $explode_patter
* @return array $num_array The unsigned integer array.
*/
function cf7a_str_array_to_uint_array( $str_array ) {
$num_array = array();
foreach ( $str_array as $value ) {
preg_match( '/^[0-9]+$/', esc_attr( $value ), $matches );
if ( $matches[0] ) {
$num_array[] = intval( $matches[0] );
return array_filter(
$str_array,
function ( $value ) {
return is_numeric( $value ) && $value > 0 && intval( $value ) == $value;
}
}
return $num_array;
);
}

0 comments on commit 948499f

Please sign in to comment.