Home>Article>Backend Development> How to delete things other than numbers in an array in php
php method to delete things other than array numbers: 1. Create a new php file; 2. Create an array; 3. Use foreach to traverse the array elements and use the is_numeric function to determine whether the numeric element is a number; 4. Output Just delete the array after non-numeric elements.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
How to delete things other than array numbers in php ?
Create a new PHP file named test.php to explain how PHP deletes non-numeric elements in an array.
In the test.php file, use the header() method to set the encoding format of the page to utf-8.
In the test.php file, create an array for testing.
In the test.php file, use foreach to traverse the array elements, use the is_numeric function to determine whether the numeric element is a number, invert the result of the determination, and use if to make the determination. , that is, if it is a non-numeric element, use the unset function to delete the currently traversed element.
In the test.php file, use print_r to output the array after removing non-numeric elements.
Open the test.php file in the browser to view the results.
Recommended study: "PHP Video Tutorial"
The above is the detailed content of How to delete things other than numbers in an array in php. For more information, please follow other related articles on the PHP Chinese website!