$semicolonCount) { $delimiter = ','; } else { $delimiter = ';'; } // The decimal separator is no longer detected here, // as it will be handled on a per-value basis. return [ 'delimiter' => $delimiter ]; } /** * Recursively traverses an array and converts numeric strings to int or float. * Non-numeric strings are left unchanged. * * @param array $array The array to process, passed by reference. */ function recursively_convert_numeric_strings(array &$array) { foreach ($array as &$value) { if (is_array($value)) { // If the value is an array, recurse into it recursively_convert_numeric_strings($value); } elseif (is_string($value) && is_numeric($value)) { // If the value is a string and represents a number, convert it // Check if it's an integer or a float if ((float)$value == (int)$value) { $value = (int)$value; } else { $value = (float)$value; } } // If it's not a string, not numeric, or not an array, it's left as is. } }