PHP code example of mcaskill / php-html-build-attributes

1. Go to this page and download the library: Download mcaskill/php-html-build-attributes library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mcaskill / php-html-build-attributes example snippets


html_build_attributes( array|object $attr [, callable $callback = null ] ) : string

$attr = [
  'type'           => 'file',
  'id'             => 'avatar',
  'name'           => 'avatar',
  'class'          => [ 'form-control', 'form-control-sm' ],
  'multiple'       => true,
  'disabled'       => false,
  'accept'         => implode(',', [ 'image/png', 'image/jpeg' ]),
  'data-max-files' => 3,
];

echo '<input ' . html_build_attributes($attr) . '>';