Guest User

Untitled

a guest
Nov 18th, 2017
385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. <?php
  2. /*
  3. * @author ri7nz <ri7nz.labs@gmail.com>
  4. */
  5. function toAttributes($arr){
  6.  
  7. $arr = array_map(
  8.  
  9. function($value, $key){
  10. return $key.'="'.$value.'"';
  11. },
  12.  
  13. array_values($arr),
  14. array_keys($arr)
  15. );
  16.  
  17. return implode(' ', $arr);
  18. }
  19.  
  20.  
  21.  
  22. $attr = array(
  23. 'id' => 'input1',
  24. 'class' => 'form-control',
  25. 'name' => 'input1'
  26. );
  27.  
  28. $attr = toAttributes($attr);
  29.  
  30. echo "<input type='text' ${attr} />";
Add Comment
Please, Sign In to add comment