protected function createTable(array $data, array $settings = []): string
    {
        $options = \array_merge([
            'name'       => null,
            'headers'    => ['Key', 'Value'],
            'vardumper'  => true,
            'empty_text' => 'Empty',
        ], $settings);

        $html = $options['name'] !== null ? '<h3>' . $options['name'] . '</h3>' : '';

        if (\count($data) !== 0) {
            $html .= '<table><thead><tr>';

            foreach ((array) $options['headers'] as $header) {
                $html .= '<th scope="col" class="' . \mb_strtolower($header) . '">' . $header . '</th>';
            }

            $html .= '</tr></thead><tbody>';

            foreach ($data as $key => $values) {
                if (\is_string($key)) {
                    $html .= '<tr>';
                    $html .= '<th>' . $key . '</th>';
                    $html .= \sprintf('<td>%s</td>', ($options['vardumper'] ? $this->cloneVar($values) : $values));
                    $html .= '</tr>';
                } else {
                    $html .= '<tr>';

                    if (\is_array($values)) {
                        foreach ($values as $k => $value) {
                            $html .= \sprintf('<td>%s</td>', ($options['vardumper'] ? $this->cloneVar($value) : $value));
                        }
                    } else {
                        $html .= \sprintf('<td>%s</td>', ($options['vardumper'] ? $this->cloneVar($values) : $values));
                    }

                    $html .= '</tr>';
                }
            }

            $html .= '</tbody></table>';
        } else {
            $html .= \sprintf('<div class="empty">%s</div>', $options['empty_text']);
        }

        return $html;
    }
protected function createTable(array $data, array $settings = []): string
    {
        $options = \array_merge([
            'name'       => null,
            'headers'    => ['Key', 'Value'],
            'vardumper'  => true,
            'empty_text' => 'Empty',
        ], $settings);

        $html = $options['name'] !== null ? '<h3>' . $options['name'] . '</h3>' : '';

        if (\count($data) !== 0) {
            $html .= '<table><thead><tr>';

            foreach ((array) $options['headers'] as $header) {
                $html .= '<th scope="col" class="' . \mb_strtolower($header) . '">' . $header . '</th>';
            }

            $html .= '</tr></thead><tbody>';

            foreach ($data as $key => $values) {
                if (\is_string($key)) {
                    $html .= '<tr>';
                    $html .= '<th>' . $key . '</th>';
                    $html .= \sprintf('<td>%s</td>', ($options['vardumper'] ? $this->cloneVar($values) : $values));
                    $html .= '</tr>';
                } else {
                    $html .= '<tr>';

                    if (\is_array($values)) {
                        foreach ($values as $k => $value) {
                            $html .= \sprintf('<td>%s</td>', ($options['vardumper'] ? $this->cloneVar($value) : $value));
                        }
                    } else {
                        $html .= \sprintf('<td>%s</td>', ($options['vardumper'] ? $this->cloneVar($values) : $values));
                    }

                    $html .= '</tr>';
                }
            }

            $html .= '</tbody></table>';
        } else {
            $html .= \sprintf('<div class="empty">%s</div>', $options['empty_text']);
        }

        return $html;
    }
protected function createTable ( array $ data , array $ settings = [ ] ) : string { $ options = \ array_merge ( [ 'name' => null , 'headers' => [ 'Key' , 'Value' ] , 'vardumper' => true , 'empty_text' => 'Empty' , ] , $ settings ) ; $ html = $ options [ 'name' ] !== null ? '<h3>' . $ options [ 'name' ] . '</h3>' : '' ; if ( \ count ( $ data ) !== 0 ) { $ html .= '<table><thead><tr>' ; foreach ( ( array ) $ options [ 'headers' ] as $ header ) { $ html .= '<th scope="col" class="' . \ mb_strtolower ( $ header ) . '">' . $ header . '</th>' ; } $ html .= '</tr></thead><tbody>' ; foreach ( $ data as $ key => $ values ) { if ( \ is_string ( $ key ) ) { $ html .= '<tr>' ; $ html .= '<th>' . $ key . '</th>' ; $ html .= \ sprintf ( '<td>%s</td>' , ( $ options [ 'vardumper' ] ? $ this -> cloneVar ( $ values ) : $ values ) ) ; $ html .= '</tr>' ; } else { $ html .= '<tr>' ; if ( \ is_array ( $ values ) ) { foreach ( $ values as $ k => $ value ) { $ html .= \ sprintf ( '<td>%s</td>' , ( $ options [ 'vardumper' ] ? $ this -> cloneVar ( $ value ) : $ value ) ) ; } } else { $ html .= \ sprintf ( '<td>%s</td>' , ( $ options [ 'vardumper' ] ? $ this -> cloneVar ( $ values ) : $ values ) ) ; } $ html .= '</tr>' ; } } $ html .= '</tbody></table>' ; } else { $ html .= \ sprintf ( '<div class="empty">%s</div>' , $ options [ 'empty_text' ] ) ; } return $ html ; }
Creates a table.

@param array $data
@param array $settings

@return string
Creates a table .