Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $input = trim(fgets(STDIN));
- $new = '';
- function replace()
- {
- global $input, $new;
- $new .= substr($input, 0, strpos($input, '<a'));
- $input = substr($input, strpos($input, 'href') + 4);
- $p = 0;
- while (true) {
- if (in_array($input[$p], array("'", '"'))) {
- $quote = $input[$p];
- break;
- }
- $p++;
- }
- $input = substr($input, $p + 1);
- $i = strpos($input, $quote);
- $new .= "[URL=" . substr($input, 0, $i) . "]";
- $input = substr($input, $i + 1);
- $i = strpos($input, '>');
- $p = strpos($input, '</a');
- $new .= substr($input, $i + 1, $p - $i - 1) . "[/URL]";
- $input = substr($input, $p + 1);
- $input = substr($input, strpos($input, '>') + 1);
- }
- while (strpos($input, 'href') > -1)
- replace();
- echo $new . $input;
Advertisement
Add Comment
Please, Sign In to add comment