Here is the working example to get select box option value and text via Simple html dom.
I assume that you have already included simple_html_dom file and have html content in $content variable
$html = new simple_html_dom(); // Creating html dom object
$html->load($content);
$i=0;
foreach($html->find('select') as $element) { // Getting all select boxes in the html
if ($element->id == 'getme') { // if you want to get content of one select box that have id *getme*
foreach($html->find('option') AS $options) { // find options of this select box
$option_val[] = $options->value; // for option value
$option_txt[] = $options->innertext; // for option text
}
}
}
0 Comment(s)