attr($name, $value = null)

Creates attributes for an HTML tag

  • $name (string or array)
    One attr name or an associative array with multiple attr names and values
  • $value (string)
    Value if $name is a string
  • return (string)

Example

<img<?php echo attr(array(
  'src'    => 'http://yourdomain.com/someimage.jpg',
  'width'  => 300,
  'height' => 200,
  'alt'    => 'Nice image'
)) ?>>