i want to find the name attribute with in a tag in a form using php4 . Does any one help me how it find..
eg
<input type="text" name="txt_name开发者_StackOverflow中文版" value="" >
I want to know name of all the fields
You need a library/code which implements an HTML DOM, look at these SO questions for more information.
When you submit a form, a url is send to the server in the form "name=value&name1=value1" etc. Here the "name" stands for the attribute "name" of an html element. So If you are using the $_GET or a $_POST then you can get the form item names in an array as follows
$names=array();
foreach($_GET as $key => $value)
{
$names[] = $key;
}
print_r($names);
You can use simple html dom as mentioned by Ignacio Vazquez-Abrams
Add it in your code like this require_once('Simple_html_dom.php');
To use it I initialized it using this line
$html = new Simple_html_dom();
Load a page or link using the line
$html->load_file('http://www.yourste.com/yourpage.php');
to parse and find this element
$e = $html->find("input", 0);
the echo the value of attribute name
echo $value = $e->name
精彩评论