$value) { $other_attributes .= $attribute . '="' . esc_attr($value) . '" '; } } ?>
include_template('info/ip-address-ip-range-info.php'); ?> '; // Check if an array is multidimensional $is_multi_dimensional = function($array) { if (!is_array($array)) { return false; } foreach ($array as $item) { if (is_array($item)) { return true; } } return false; }; // Check if the input data is a multidimensional array if ($is_multi_dimensional($data)) { // Add table headers based on the keys of the first array element $table_html .= ''; foreach (array_keys($data[0]) as $header) { $table_html .= '' . esc_html($header) . ''; } $table_html .= ''; // Recursively format the multidimensional array $table_html .= self::format_data_recursive($data); } else { // If the input data is not a multidimensional array, treat it as a single key-value pair $table_html .= self::format_data_recursive(array($data)); } $table_html .= ''; return $table_html; } /** * Recursively format data as a table * * @param array $data Data to be formatted * * @return string Formatted data as a table */ private static function format_data_recursive($data) { $html = ''; foreach ($data as $key => $value) { if (is_array($value)) { // If the value is an array, recursively format it $html .= self::format_data_recursive($value); } else { // If the value is not an array, format it as a table row $escaped_key = esc_html($key); $escaped_value = esc_html($value); $html .= '' . $escaped_key . '' . $escaped_value . ''; } } return $html; } }