Your Ad Here

Home » PHP Code »

0

The following script will help you to create auto hyperlinks using php code.

our string :

1
$string = " this is blog of anil kumar panigrahi http://www.anil2u.info";

call the function like

1
addLink($string);

below code will be split into sting + hyperlink url.

1
2
3
4
5
6
7
8
9
function addLink($string){
$breakstring = explode(" ", $string);
for ($i=0; $i<=sizeof($breakstring)-1; $i++)
{
if ((substr($breakstring[$i], 0, 7) == 'http://') &&$breakstring[$i] != 'http://'))
$string = str_replace($breakstring[$i], "<a href="'.$breakstring[$i].'">".$breakstring[$i]."</a>", $string);
}
return $string;
}

Hope that it will be useful.


You may like these posts

    How to connect to FTP and upload file using php code?Searching for existing domain names?Make thumb using php with respect the ratio width and  heightInactive in site then auto logout using php

 

Leave a Reply