我想使用xpath顯示id的值,但是我得到的只是nodeName是h4,而nodeValue只是空白或none.Hope任何人都可以幫助我,因爲我不熟悉dom。我通過研究得到了這個想法。回聲如何使用Dom獲取id從html標記到php的值
完整的結果: {[4-
<?php
// Value of this echo is 5 which is I want to echo inside foreach
echo $html='<h4 id="image-gallery-count"></h4>';
$doc = new DOMDocument();
$doc->loadHTML($html);
$xpath = new DOMXPath($doc);
$result = $xpath->evaluate("//h4[@id='image-gallery-count']");
foreach ($result as $node) {
echo "{$node->nodeName} - {$node->nodeValue}";
}
// This somewhat like $count= {$node->nodeValue}
$c = chr(64 + $count);
$b = chr(64 + 1);
?>
//這裏是我的腳本,隨着5
$('#image-gallery-count').text($sel.data('count'));
的值傳遞id的值我一個行代碼
//如果我只能得到這個id的值,我會用這個整數在$ c = chr(64 + 5);內部添加。出於某種原因,我想用它迭代forloop來顯示一些東西。 ..
下面是循環:任何屬性的
@for ($i = $b; $i <= $c; $i++)
<img id="image-gallery-image-{!! $i !!}" class="img-responsive" src="">
@endfor