Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert string array to integer array in php

Tags:

arrays

php

I have an array:

$TaxIds=array(2) { [0]=> string(1) "5" [1]=> string(2) "10" } 

I need convert to this:

$TaxIds=array(2) { [0]=> int(5) [1]=> int(10) } 

simple way???

like image 853
Fatemeh Namkhah Avatar asked Nov 29 '22 10:11

Fatemeh Namkhah


1 Answers

Simplified version of @george's answer would be:

$TaxIds = array_map('intval', $TaxIds);

More info at array_map

Although the question was asked a long time ago, it may be useful for someone

like image 192
Qudratxo'ja Musayev Avatar answered Dec 06 '22 09:12

Qudratxo'ja Musayev