I’m studying JavaScript right now and learned that you can, for example, read the data within all the <h1> tags on a page and create links to them somewhere else in the page.
Perhaps I’m having a brain burp, but can you do this with PHP also? Like, search all the <h1> tags in a page (the equivalent in JavaScript is document.getElementsByTagName(“h1”)), get their content (innerHTML), and then use those Strings somewhere else in the page (to maybe, make links)?
Hopefully I’ve been clear with my question, and this is probably possible, I think I’m just forgetting or not thinking properly on how to do it.
Yes, you can parse text in any programming language. You can either use an XML parser and treat the webpage as an XML document, or you can use regular expressions and just look for patterns in the text (like the letters <h1> followed by some text followed by </h1>).