从另一个页面计算<LI>元素

I have two pages, page A and page B. Page A will hold an unknown number of unordered list elements. I wont have any control on how many list elements there are.

On Page B, I'd like to use PHP to grab the number of li from Page A and display that number. The idea is Page A will hold Wordpress post links that a user has favorited, while Page B will display that amount of favorites.

Any help would be wonderful. Thanks

Parse html from another page using PHP Simple HTML DOM Parser. Download it and include to your script:

include('simple_html_dom.php');
$html = file_get_html('http://example.com/yourpage.php');
$licount = count($html->find('li')); // Here it is

Okay. Looks like OP don't need to use serverside code. Use javascript for this (don't forget to include jQuery):

$(document).ready(function(){
    $.get("/favorites", function(data){
        $("#favorites").html($("li", $(data)).length)
    })
})

This will replace content of element #favorites with number of lis in /favorites file