Here's an example of what I mean:
I have an array:
array('type'=>'text',
'class'=>'input',
'name'=>'username',
'id'=>'username',
'value'=>'',
'size'=>'30',
'rows'=>'',
'cols'=>'');
Then, I loop through it like so:
$input = '<input ';
foreach($input_array as $key => $value) {
if(isset($key) && !empty($key)) {
$input .= $key . '="' . $value . '" ';
}
}
$input .= '/>';
I'm hoping to return:
<input type="text" class="input" name="username" id="username" size="30" />
I've tried using PHP's sort() functions to no avail. The nearest I can figure is I'd need to use something like usort(), but I'm having trouble figuring how to write a function which will do what I want.
Any advice on this topic is greatly appreciated, and thanks very much for reading.