Removing non-integer entries from array in php
Here we are going to discuss how to remove strings or non-integer values from an array in php.
For this we need to use one simple array function in php called array_filter() . it always filters an array using a callback function.
array_filter(array, callbackfunction, flag)
- array :- required, is the array to be filtered
- callbackfunction :- optional, the callback function
- flag :- optional, Specifies what arguments are sent to callback
array( => 1,  => 'one',  => 2,  => 'two',  => 3);
Expected Result :
array( => 1,  => 2,  => 3);
$result = array_filter($array, 'is_numeric');
Here you dont have to do any other steps as ‘is_numeric’ is a built in function, all you have to do is just call this line.
Click me for more intersting PHP Solutions.