Simple way for casting array of values to int
Published on 06.10.2014
Here is a simple way to cast all elements in array to integeres in php
$array = array('1', '24', 'da','fa24'); $array = array_map('intval', $array);And yes it have overhead but for small arrays it is ideal solution instead of writing a classical foreach loop
$array = array('1', '24', 'da','fa24'); foreach($array as $k =>$v) { $array[$k] = (int)$v; }