Is there a better way of doing this than looping through the array with a foreach and converting each string to int? php string int explode. share php: convert array type values from string to int selectively. 0. Here is a type conversion from string to int, the same way, with PHP MySQL. Basically, you can change the type of your string by adding 0. PHP functions that convert strings to arrays: explode splits a string on a If I have this array array(1,2,3) How can I convert this integer value to string array("1","2","3").Let me try to answer your both questions. You can convert an INT array to String array in PHP using following way One solution is looping over the array, but I dont want to do that. Can I achieve the above using only php functions?str "24,27,38" result arraymap(function(v) return (int) trim(v, "") , explode(",", str)) vardump(result) The last two print blocks prints the type of an array element before and after conversion. The output is string in both the cases.How to add position to my stock portfolio, currently getting an error about incompatible types cannot be converted to int or String. Preparation. Just creating an array of 1 million random integers between 0 and 100. Than, I imploded them to get the string.Easiest way to convert int to string in C.