我建立一個基本形式的建築類,以加快我的工作流了一點,我想能夠採取的屬性的數組,像這樣:如何將關聯數組映射到html元素屬性?
$attributes = array(
"type" => "text",
"id" => "contact-name",
"name" => "contact-name",
"required" => true
);
和地圖,爲的屬性html元素:
<input type="text" id="contact-name" name="contact-name" required />
編輯:
什麼是實現上述的清潔方法是什麼?我確信我可以用一個循環和一些連接拼湊一些東西,但是我感覺printf或類似的東西可以以更優雅的方式做到這一點。
那麼問題是什麼? –
所以,如果你建立了這樣一個班級,你可能試過一些東西?和@nostrzak說什麼;) – dbf
我沒有得到它,問題在哪裏,或者你想要做什麼:] –