PHP Treat String as Variable
Posted
by Ygam
on Stack Overflow
See other posts from Stack Overflow
or by Ygam
Published on 2010-03-30T06:44:05Z
Indexed on
2010/03/30
6:53 UTC
Read the original article
Hit count: 336
php
Hi guys. I have a piece of code here that does not work despite me using a $$ on it to treat the string as a variable:
<? foreach (KOHANA::config('list.amenities_forms') as $k => $v) : ?>
<div class="form">
<fieldset>
<legend><?php echo $v ?></legend>
<input type="checkbox" name="<?=$k?>flag" id="<?=$k?>flag"/>
<label class="inline"><?=$v?></label>
<label>Description</label>
<textarea cols="50" rows="5" name="<?=$k?>[]"><?= empty($$k[0]) ? '' : $$k[0]?></textarea>
<label>Size</label>
<input type="text" name="<?=$k?>[]" value="<?= empty($$k[1]) ? '' : $$k[1]?>"/>
<label>Capacity</label>
<input type="text" name="<?=$k?>[]" value="<?= empty($$k[2]) ? '' : $$k[2]?>"/>
</fieldset>
</div>
<? endforeach?>
the function Kohana::config returns this array:
'amenities_forms' => array(
'meeting_space' => 'Meeting Space',
'breakfast_room' => 'Breakfast Room',
'living_quarters' => 'Living Quarters',
'restaurant' => 'Restaurant',
'bar' => 'Bar'
)
what could I be doing wrong?
© Stack Overflow or respective owner