amund/html

A PHP library for generating HTML content from PHP arrays.

1.0.1 2025-04-20 22:17 UTC

This package is auto-updated.

Last update: 2025-04-20 22:18:22 UTC


README

A PHP library for generating HTML content from PHP arrays.

Installation

composer require amund/html

Usage

Generating single tags

Use the tag method to generate single HTML tags.

echo html::tag('div', ['class'=>'test'], 'Hello World');

// Output: <div class="test">Hello World</div>

Rendering HTML content

Use the render method to render HTML content from an array.

$data = [
    'tag' => 'div',
    'class' => 'test',
    'content' => [
        'Hello ',
        [
            'tag'=>'b',
            'content'=>'World'
        ],
        ' !',
    ],
];

echo html::render($data);

// Output: <div class="test">Hello <b>World</b> !</div>