我正在使用此代碼來檢索標籤。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,所以原諒我的無知 –