Last active
December 22, 2017 10:21
-
-
Save zvineyard/fa7a993f7cb198c982bf to your computer and use it in GitHub Desktop.
Typo3: Convert <link> to <a> Regex PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function convert_external_link_tags($html) | |
{ | |
$pattern = '/<link\s(.+)\s-\s(.*)?\s(".*")?>(.+)<\/link>/U'; | |
$replacement = '<a href="$1" target="$2" title=$3>$4</a>'; | |
preg_match_all($pattern, $html, $matches, PREG_PATTERN_ORDER); | |
return preg_replace($pattern, $replacement, $html); | |
} | |
function convert_internal_link_tags($html) | |
{ | |
$pattern = '/<link\s([0-9]+)>(.+)<\/link>/U'; | |
$replacement = '<a href="http://www.nnu.edu/index.php?id=$1">$2</a>'; | |
preg_match_all($pattern, $html, $matches, PREG_PATTERN_ORDER); | |
return preg_replace($pattern, $replacement, $html); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Many Thanks!