Skip to content

Instantly share code, notes, and snippets.

@aldolat
Created October 26, 2013 08:33
Show Gist options
  • Save aldolat/7166803 to your computer and use it in GitHub Desktop.
Save aldolat/7166803 to your computer and use it in GitHub Desktop.
Filter an array and return only numeric elements
<?php
function is_number( $value ) {
if ( is_numeric( $value ) ) return true;
}
$arr = array( 'one', 2, 'three', 15 );
$b = array_values( array_filter( $arr, 'is_number') );
print_r( $b );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment