Created
June 1, 2017 04:19
-
-
Save andimariadi/b537494c877b02fd620d817970c8137e to your computer and use it in GitHub Desktop.
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 | |
| $string = 'Hai ini <a href="http://google.com">Google</a> dan ini <a href="http://pemulabelajar.com">Pemula Belajar</a>'; | |
| function plainUrls($string) { | |
| $regex = '/https?://[^"]+/i'; | |
| if (preg_match($regex, $string, $matches)) { | |
| return preg_replace($regex, "safelink.php?go=".base64_encode($matches[0]), $string); | |
| } else { | |
| return $string; | |
| } | |
| } | |
| echo plainUrls($string); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment