Answer the question
In order to leave comments, you need to log in
How to parse link names in php?
Good day, I ran into a problem, the customer has an old site, but there is no access to the database.
You need to parse category link names, the link structure is simple:
<a href="/clothing/jacket/">Jacket</a>
<a href="/clothing/Socks/">Socks</a>
Answer the question
In order to leave comments, you need to log in
- Global variables
- Hard-coded classes
If you're going to use it as a plugin, then no. If it works on your project and suits you - ok.
better wrap it in at least a closure so that your code doesn't pollute the global window object.
$html = file_get_contents("http://site.org/path/index.php");
if (preg_match_all("#<a href=\"[^\"]+\">(.+?)</a>#", $html, $regs, PREG_PATTERN_ORDER))
{
foreach($regs[1] as $v) echo("{$v}\n");
}
This is some kind of sur. Access to the database was stolen by aliens?
Well, here is a regular expression, for example https://regex101.com/r/TuQdqY/1/
Or read about some normal parser, such as dom-crawler, DiDom or zend_dom_query
but no db access.What about the code? Or the customer does not have a website at all, but whose website xs?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question