Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Search and remove numeric array value

Tags:

php

I have a php array with strings and I'd like to delete the keys that have a string containing only numbers.

How can I do that?

like image 564
DanCapitanDePlai Avatar asked Nov 30 '22 13:11

DanCapitanDePlai


1 Answers

Filtering the array would be the most elegant way:

$array = array_filter($array, 'is_numeric');

This returns an array with only those values for whom is_numeric() is true.

like image 111
pilsetnieks Avatar answered Dec 05 '22 23:12

pilsetnieks