Created
October 26, 2013 08:33
-
-
Save aldolat/7166803 to your computer and use it in GitHub Desktop.
Filter an array and return only numeric elements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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