Jump to content

Recommended Posts

Its called Linkparse, i found in one of my folders (not sure if its been ripped from elsewhere) and i think its a script that auto changes www.somelink.com to a valid www.somelink.com link without the need to enter the markup, (but i don't know)

 

ive tried it in a few documents, uploaded them and tried it out but nothing has happened (in regards to me "guess")

<?php
function convertLinks($text) {
    $text = preg_replace("/(\r\n|\n|\r)/", "\n", $text);
    $lines = explode("\n", $text);
    for ($x = 0, $y = count($lines); $x < $y; $x++) {
        $line = $lines[$x];
        $words = explode(' ', $line);
        for ($i = 0, $j = count($words); $i < $j; $i++) {
            $word = $words[$i];
            $punctuation = '.,\'")(<>;:'; // Links may not end in these
            if (substr($word, 0, 7) == 'http://' || 
                    substr($word, 0, 4) == 'www.') {
                $trailing = '';
                // Knock off ending punctuation
                $last = substr($word, -1);
                while (strpos($punctuation, $last) !== false) {
                    // Last character is punctuation - eliminate it
                    $trailing .= $last;
                    $word = substr($word, 0, -1);
                    $last = substr($word, -1);
                }
                // Make link, add trailing punctuation back afterwards
                $link = $word;
                if (substr($link, 0, 4) == 'www.') {
                    // This link needs an http://
                    $link = 'http://'.$link;
                }
                $word = '<a href="'.$link.'" target="_BLANK">'.$word.'</a>'.$trailing;
            }
            $words[$i] = $word;
        }
        $lines[$x] = implode(' ', $words);
    }
    return implode("\n", $lines);
}
$link = "www.somelink.com";
echo $output = convertLinks($link);

?>

 

If this is what i "think" it is could someone please tell/explain how I'd get it to work .

 

Or if it's something else i wouldnt mind knowing what it is/does  :)

 

Thank you

 

AA

 

 

Link to comment
https://forums.phpfreaks.com/topic/67433-could-anyone-tell-me-what-this-isdoes/
Share on other sites

sorry for the late reply, just beena bit busy

 

anywho's

 

thanks wildteen88

i know how to use it now i just wasn't determining what needs to be parsed so it was just sitting there like a lemon  :D.

 

i've re-jigged it a llittle tidied it up a bit, but im now faced with another problem ...

 

<?php
function parse($sample){	

$Ngram = array();
$text = nl2br($sample);

$Ngram = explode(" ", $text);

for($i=0; $i<count($Ngram); $i++){

	if(strlen($Ngram[$i]) >= 9){	

		if(substr($Ngram[$i],0,4) == "www."){

			if(substr($Ngram[$i],-1,1) == "."){
				$length = strlen($Ngram[$i])- 1;
				$Ngram[$i] = substr($Ngram[$i],0,$length);
			}

			$Ngram[$i] = strip_tags($Ngram[$i]);				

		$tmp = "<a href=\"http://" . $Ngram[$i] . "\" target=\"_BLANK\">" . $Ngram[$i] . "</a>";
			$Ngram[$i] = $tmp;
		} 
				} 
} 

for($i=0; $i<count($Ngram); $i++){

$parsed .= $Ngram[$i] . " ";
} 

return $parsed;
}

?>  

 

i would like it to parse mail:to links , but i cant fathom out what to put and where and its driving me nuts, if anyone has a suggestion please let me know?

 

cheers

 

AA

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.