amund / html
A PHP library for generating HTML content from PHP arrays.
1.0.1
2025-04-20 22:17 UTC
Requires
- php: >=8.0
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.0
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>