从每个td获取值(Get the values from each td)
我使用phpQuery从元素中获取数据。
我试图从每个
tr
第一个td
,secondstd
和href
链接中获取值。<table> <tr class="A2"> <td> Text 1 </td> <td> Text 2 </td> <td> Text 3 </td> <td> <a href="linkhere1"> Text 131</a> </td> </tr> <tr class="A2"> <td> Text 4 </td> <td> Text 5 </td> <td> Text 6 </td> <td> <a href="linkhere2"> Text 123213</a> </td> </tr> <tr class="A2"> <td> Text 7 </td> <td> Text 8 </td> <td> Text 9 </td> <td> <a href="linkhere3.php"> Text 213213 </a> </td> </tr> </table>
这个怎么做? 我努力了:
<? require('phpQuery.php'); $file = file_get_contents('test.txt', true); $html = phpQuery::newDocument($file); foreach($html->find('.A2') as $tag) { echo pq('td'); // problem here? } ?>
I am using phpQuery to get the data from elements.
I'm trying to get the values from first
td
, secondstd
andhref
link from eachtr
.<table> <tr class="A2"> <td> Text 1 </td> <td> Text 2 </td> <td> Text 3 </td> <td> <a href="linkhere1"> Text 131</a> </td> </tr> <tr class="A2"> <td> Text 4 </td> <td> Text 5 </td> <td> Text 6 </td> <td> <a href="linkhere2"> Text 123213</a> </td> </tr> <tr class="A2"> <td> Text 7 </td> <td> Text 8 </td> <td> Text 9 </td> <td> <a href="linkhere3.php"> Text 213213 </a> </td> </tr> </table>
How to do this? I have tried:
<? require('phpQuery.php'); $file = file_get_contents('test.txt', true); $html = phpQuery::newDocument($file); foreach($html->find('.A2') as $tag) { echo pq('td'); // problem here? } ?>
原文:https://stackoverflow.com/questions/5994022
最满意答案
我可以通过在PEAR目录之前将它添加到PHP的包含路径来使其工作:
include_path = ".;c:\path\to\php-code-coverage;C:\programme\php\pear" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
现在调用PHPUnit使用标准包但
CodeCoverage
的开发版本。 不需要符号链接,编辑php.ini就足够了。I could get it to work by adding it to PHP's include path before the PEAR dir:
include_path = ".;c:\path\to\php-code-coverage;C:\programme\php\pear" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Invoking PHPUnit now uses the standard package but the development version of
CodeCoverage
. No symbolic linking required, editing php.ini is enough.
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
我认为你使用了错误的注册表文件。 尝试将PEAR安装目录作为第一个参数传递给PEAR_Registry构造函数。 它是.registry目录所在的目录,例如/usr/share/php/ 。 I think you're using the wrong registry file. Try to pass the PEAR installation directory as first parameter to the PEAR_Registry constructor. It's the director ...
-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
修改系统环境变量。 请参阅PEAR手册中的第二段: 最后,您必须将该安装路径添加到PATH环境中。 可以手动执行此操作(“开始”>“控制面板”>“系统”>“环境”),也可以运行(双击)现在在PHP源目录中找到的新生成的PEAR_ENV.reg。 Modify your system environment variables. See the second paragraph in the PEAR manual: Finally you have to add that installation path ...
-
我做了一些挖掘,这似乎解决了PHP版本问题: sudo /Applications/MAMP/bin/php/php5.3.6/bin/pear config-set php_dir /Applications/MAMP/bin/php/php5.3.6/lib/php/ sudo /Applications/MAMP/bin/php/php5.3.6/bin/pear config-set doc_dir /Applications/MAMP/bin/php/php5.3.6/lib/php/doc/ s ...
-
我可以通过在PEAR目录之前将它添加到PHP的包含路径来使其工作: include_path = ".;c:\path\to\php-code-coverage;C:\programme\php\pear" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 现在调用PHPUnit使用标准包但 CodeCoverage的开发版本。 不需要符号链接,编辑php.ini就足够了。 I could get it to work by adding it to PHP's ...
-
好的我明白了。 absalon.valdes是对的。 $table = \Console_Table(); 是解决方案。 重要的是在Eclipse中做一个干净的项目构建。 之后,编译器识别该类。 我的错。 谢谢。 Ok, I get it. absalon.valdes was right. $table = \Console_Table(); is the solution. Important was to do a clean build of the project in Eclipse. Afte ...
-
啊,刚刚意识到HTTP_Download2只是一个占位符,而代码只出现在Github上(我之前使用过它,但是它有一些依赖项没有编写器文件,我认为使用PEAR会更快过分叉那些项目)。 恢复到HTTP_Download修复了该问题。 梨死了? :P Ah, just realized HTTP_Download2 is just a placeholder, while the code is only up at Github (which I was using before, but some of th ...
-
错误消息指出PHPUnit位于此pear目录中: /usr/local/pear/share/pear/PHPUnit 这应转换为此路径以添加到include_path设置: /usr/local/pear/share/pear 您当前定义了/usr/local/bin/PEAR ,这看起来很奇怪。 特别是因为安装说明应该是/usr/local/PEAR ,但这取决于PEAR的实际安装方式。 The error message states that PHPUnit is located in this ...
-
让PEAR使用github通道(Make PEAR use github channel)[2023-08-31]
包的源代码只移动到git,而不是包发布本身。 Github将显示更新的提交,但提交!=发布 - 您将不得不等待包发布以获取最新的源代码更改。 这与我们使用SVN(以前的CVS)来托管代码的过去12年没有什么不同。 他们只是不像github那样可见。 The source code of the packages only moved to git, not the package releases themselves. Github will show newer commits, but commits ...