how to check if an element in an html file exists in another html file? [closed]

If I understand you correctly, and you want to find an HTML element inside another page, you need to use some HTML parser.

Take a look at https://www.php.net/manual/en/domdocument.loadhtmlfile.php or https://github.com/paquettg/php-html-parser. I believe there are more tools that can help you with this.

On page B you load page A as a remote document by URL, then parse it and look for the desired HTML element.