I have an array in PHP, which may contain elements of various types. How can I keep only the elements that are strings, and remove all the others?
I know I can do
foreach ($array as $key => $val)
if (gettype($val) !== 'string')
unset($array[$key]);
But I would like an easier way to do it.
Note: I don't care about the array's keys and whether they stay the same or not.