1 回答

TA貢獻(xiàn)2080條經(jīng)驗(yàn) 獲得超4個(gè)贊
我認(rèn)為您正在尋找服務(wù)器端JQuery
,它實(shí)際上存在!
使用示例
在您的具體情況下,它可以這樣使用:
<?php
include 'phpQuery.php';
$str = '<span country="US"></span><a href="url-here">some text</a>';
$doc = phpQuery::newDocument($str);
// Note that we can use CSS style selector,
// instead of just "span".
$links = array();
foreach($doc['span'] as $item)
{
? $node = pq($item);
? $sibling = $node->next();
? if ( $sibling->is('a') ) {
? ? $links[] = array(
? ? ? $node->attr('country'),
? ? ? $sibling->attr('href'),
? ? ? $sibling->text(),
? ? );
? }
}
// Display result:
print_r($links);
只需獲取phpQuery-0.9.5.386-onefile.zip,將其解壓并將其重命名為phpQuery.php
,它是一個(gè)文件!
- 1 回答
- 0 關(guān)注
- 133 瀏覽
添加回答
舉報(bào)