So I have a form that has 4 inputs, 2 text, 2 hidden. I\'ve grabbed the two text input values from the name, which are (get_me_two, get_me_three) and I\'ve also grabbed the
I don't use the SimpleDom (I always go whole-hog and use DOMDocument), but couldn't you do something like ->find('input[@type=hidden]')
?
If the SimpleDOM doesn't allow that sort of selector, you could simply loop over the ->find('input')
results and pick out the hidden ones by comparing the attributes yourself.
If you use DomDocument
, you could do the following:
<?php
$hidden_inputs = array();
$dom = new DOMDocument('1.0');
@$dom->loadHTMLFile('form_show.php');
// 1. get all inputs
$nodes = $dom->getElementsByTagName('input');
// 2. loop through elements
foreach($nodes as $node) {
if($node->hasAttributes()) {
foreach($node->attributes as $attribute) {
if($attribute->nodeName == 'type' && $attribute->nodeValue == 'hidden') {
$hidden_inputs[] = $node;
}
}
}
} unset($node);
// 3. loop through hidden inputs and print HTML
foreach($hidden_inputs as $node) {
echo "<pre>" . htmlspecialchars($dom->saveHTML($node)) . "</pre>";
} unset($node);
?>