Created
April 10, 2022 17:08
-
-
Save estefanionsantos/74a712caef8b742e8da0d19363d466d1 to your computer and use it in GitHub Desktop.
select element
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 | |
use Rubricate\Element\CreateElement; | |
use Rubricate\Element\StrElement; | |
$select = new CreateElement('select'); | |
$select->setAttribute('name', 'latim'); | |
$opt[] = 'lorem'; | |
$opt[] = 'ipsum'; | |
$opt[] = 'dolor'; | |
foreach ($opt as $value => $text){ | |
$option = new CreateElement('option'); | |
$option->setAttribute('value', $value); | |
$option->addChild(new StrElement($text)); | |
$select->addChild($option); | |
} | |
echo $select->getElement(); | |
/* | |
<select name="latim"> | |
<option value="0">lorem</option> | |
<option value="1">ipsum</option> | |
<option value="2">dolor</option> | |
</select> | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment