EG
Size: a a a
СШ
Е
$modx->resource->content;
$links = $dom->getElementsByTagName('a');
foreach ($links as $link) {
$href = $link->getAttribute('href');
$href = urldecode($href);
$href = str_replace('/%5B', '[', $href);
$href = str_replace('/%5D', ']', $href);
$link->setAttribute('href', $href);
$link->setAttribute('data-href', $href);
}
СШ
Е
EG
S
S
EG
СШ
S
СШ
АС
$modx->resource->content;
$links = $dom->getElementsByTagName('a');
foreach ($links as $link) {
$href = $link->getAttribute('href');
$href = urldecode($href);
$href = str_replace('/%5B', '[', $href);
$href = str_replace('/%5D', ']', $href);
$link->setAttribute('href', $href);
$link->setAttribute('data-href', $href);
}
АС
$modx->resource->content;
$links = $dom->getElementsByTagName('a');
foreach ($links as $link) {
$href = $link->getAttribute('href');
$href = urldecode($href);
$href = str_replace('/%5B', '[', $href);
$href = str_replace('/%5D', ']', $href);
$link->setAttribute('href', $href);
$link->setAttribute('data-href', $href);
}
Е
$dom = new DOMDocument;Я поставил отладчик после $test. Почему в $test получается такое значение?
$dom->loadHTML('<div>' . $content . '</div>', LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$root = $dom->documentElement;
$links = $dom->getElementsByTagName('a');
foreach ($links as $link) {
$href = $link->getAttribute('href');
$href = urldecode($href);
$link->setAttribute('href', $href);
$link->setAttribute('data-href', $href);
$test = $dom->saveHTML($link);
}
<a href="/%5B%5B~999%5D%5D" data-href="/[[~999]]">Мы выпускаем</a>Почему href и data-href разные?
EG
MK
АС
$dom = new DOMDocument;Я поставил отладчик после $test. Почему в $test получается такое значение?
$dom->loadHTML('<div>' . $content . '</div>', LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$root = $dom->documentElement;
$links = $dom->getElementsByTagName('a');
foreach ($links as $link) {
$href = $link->getAttribute('href');
$href = urldecode($href);
$link->setAttribute('href', $href);
$link->setAttribute('data-href', $href);
$test = $dom->saveHTML($link);
}
<a href="/%5B%5B~999%5D%5D" data-href="/[[~999]]">Мы выпускаем</a>Почему href и data-href разные?