I am using a function in a separate file, that gets should return me an array containing the enum values of a field:
<?php
function getEnumValues($table, $field) {
$enum_array = array();
$query = "SHOW COLUMNS FROM '{$table}' WHERE Field = '{$field}'";
$result = mysqli_query($query);
$row = mysqli_fetch_row($result);
preg_match_all('/\'(.*?)\'/', $row[1], $enum_array);
return $enum_array;
}
?>
and in the main file, I do this:
<?php
require 'common.php';
for ($i=0; $i <= 5; $i++) {
getEnumValues(property, value_type);
echo "<input type='radio' name='tipo_valor' value='$enum_array[$i]' required>" . ' ' .$enum_array[$i] . '<br>';
}
?>
The problem is that the function returns nothing.
So is the function ok for what I need? And can I use a variable returned in another file, as a local variable?
Thanks for your time, and suggestions!