note 105951 deleted from function.implode by danbrown
| From: | danbrown@php.net | Date: | Tue, 27 Sep 2011 14:24:17 +0000 |
| Subject: | note 105951 deleted from function.implode by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-183488@lists.php.net to get a copy of this message | ||
Note Submitter: ethaizone at hotmail dot com
----
Another version imploding an associative of "tl at magus dot dk" (look below)
<?php
$assoc_array = array(
'name' => 'username',
'id' => 'username',
'value' => 'johndoe',
'maxlength' => '100',
'size' => '50',
'style' => 'width:50%',
);
array_walk($assoc_array, create_function('&$v, $k', '$v =
$k."=\"".$v."\"";'));
//stand for form_input() in codeigniter
print '<input type="text" '.implode($assoc_array, ' ').'
/>';
?>
Output:
<input type="text" name="username" id="username"
value="johndoe" maxlength="100" size="50" style="width:50%"
/>
I use this code for form_dropdown() in codeigniter to pass it as a string in the fourth parameter.