I have a string like this: '3,6,43,8'
.
I can convert it to an array easily:
$newArray = explode( ',', $string );
but as I need integer elements in the array, I should convert every array element to an integer:
foreach( $newArray as $key => $sNumber ) {
$newArray[ $key ] = intval( $sNumber );
}
Is there a way to directly convert the array elements to integers, instead of strings?