Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fix datatype associative array
<?php
public static function correctTypes($arr) {
foreach ($arr as $key => $value) {
if(is_numeric($value))
$arr[$key] = (int) $value;
elseif(is_array($value))
$arr[$key] = self::correctTypes($value);
}
return $arr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment