我正在使用此代码来检索标签。PHP查询什么标签是单词。
$title = $pq->find("title")->text();
$h1 = $pq->find("h1")->text();
$p = $pq->find("p")->text();
这是正确的做法吗?
其次,我必须看看我的数组$array_words
中的单词是在哪个标记中。所以我已经检索了file_get_contents
并删除了所有标签并将所有单词放入数组中。现在,让我们借此例如:
Array
(
[0] => hello
[1] => there
[2] => this
[3] => is
[4] => a
[8] => test
[9] => array
)
,这将是HTML:
<html>
<head>
<title>
hello there
</title>
</head>
<body>
<h1>
this is a
</h1>
<p>
test array
</p>
</body>
</html>
我如何可以找出哪些字,其中标签被发现的?
我希望我略微清楚自己想要做什么。
你在使用什么库,或女巫班是你在$ pq变量instanciating? –
@MauricioPiberFão'$ pq = phpQuery :: newDocument($ file);'这是我如何设置'$ pq'如果这就是你的意思= /库不是只是PHP 5?我是新来的phpquery,所以原谅我的无知 –