Created
May 16, 2014 09:37
-
-
Save SimonJThompson/db47d457a65d034c441c to your computer and use it in GitHub Desktop.
Function to convert an associative array to a string of HTML element attributes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Takes an associative array and converts them to HTML element attributes | |
*/ | |
function array_to_attr($attrs) { | |
$r=""; | |
if(is_array($attrs)) { | |
foreach($attrs as $attr => $val) { | |
$r.=$attr.="=\"".$val."\" "; | |
} | |
} | |
return $r; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment