Okay so I am stuck here and I know there would be a simple solution, but I can't figure it out. So the thing is that I have a function which creates columns in a database if not exists. I got the function to work but I want to add the functionality in the function of detecting the column type (VARCHAR, INT etc) and creating columns accordingly. I am trying to get this done by gettype
keyword. Now, $productData
is in array so I need to apply foreach to get them separated and then I get the value type, the problem is that in the end foreach loop, it gives me only string. Where $productData
has 4 strings and 1 integer ..
$array = (array) $productData;
$arrayValues = array_values( $array );
$i = 0;
foreach ( $arrayValues as $key => $value ) {
$types = array( "id-$i" => gettype( $value ) );
$i++;
}
var_dump($types);
Can somebody help me out there please?
Thanks ..