Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP简单html dom查找所有输入[type=text]或没有类型_Php_Simple Html Dom - Fatal编程技术网

PHP简单html dom查找所有输入[type=text]或没有类型

PHP简单html dom查找所有输入[type=text]或没有类型,php,simple-html-dom,Php,Simple Html Dom,我试图提取所有表单输入,它们的类型是文本 我的问题是,至少在Chrome中,输入标记没有指定类型属性,被呈现为文本 我如何找到其类型未指定的所有标记,或者其值是文本,使用简单html dom 我现在: foreach ($form->find('input[type=text]') as $input) 读这个 我不确定,但试试这个 $html->find('input[type=text]', 0); 恐怕您必须这样做: foreach ($form->find('in

我试图提取所有表单输入,它们的
类型是
文本

我的问题是,至少在Chrome中,
输入
标记没有指定
类型
属性,被呈现为
文本

我如何找到其
类型
未指定的所有标记,或者其值是
文本
,使用简单html dom

我现在:

foreach ($form->find('input[type=text]') as $input)
读这个

我不确定,但试试这个

$html->find('input[type=text]', 0);

恐怕您必须这样做:

foreach ($form->find('input') as $input){
  if($input->type==''||$input->type=='text'){
    //code
  }
}
除非解析器可以使用这种类型的选择器:
input[type='',input[type=text]


在JQuery中,这将选择没有类型或类型等于text的所有元素。

您的示例只选择第n个元素。无论如何,我决定迭代整个输入并检查它们的类型,如果是文本,或者是空的。谢谢你的帮助。