<?php
$str = "Hi I am using google.com going http://google.com and
where in https://google.com ahcinkg http://google.co.in else http://google.co";
$ss = "";
$sd = explode(" ",$str);
//print_r($sd);
$c=count($sd)."
";
$i=0;
while($c>$i){
$regex = "((https?|ftp)\:\/\/)?"; // SCHEME
$regex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?"; // User and Pass
$regex .= "([a-z0-9-.]*)\.([a-z]{2,4})"; // Host or IP
$regex .= "(\:[0-9]{2,5})?"; // Port
$regex .= "(\/([a-z0-9+\$_-]\.?)+)*\/?"; // Path
$regex .= "(\?[a-z+&\$_.-][a-z0-9;:@&%=+\/\$_.-]*)?"; // GET Query
$regex .= "(#[a-z_.-][a-z0-9+\$_.-]*)?"; // Anchor
// $regexp = '/^[a-zA-Z0-9][a-zA-Z0-9\-\_]+[a-zA-Z0-9]$/';
if (true == preg_match("/^$regex$/", $sd[$i])) {
if(!in_array("http", parse_url($sd[$i])) && !in_array("https", parse_url($sd[$i]))) {
$s1 ="http://".$sd[$i];
echo $ss ="$sd[$i] ";
}elseif(in_array("http", parse_url($sd[$i])) || in_array("https", parse_url($sd[$i]))) {
echo $ss ="$sd[$i] ";
}
}else{
echo $sd[$i]." ";
}
$i++;
}
?>
Html, JAVA,DOTNET,Javascript, PHP, and JQuery Scripts and its issues with solutions
Thursday, 27 November 2014
To find url given string and replace with anchor tag in php
Subscribe to:
Post Comments (Atom)
Feet/Inches to Meters Converter & Lbs to Kgs Converter
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>Feet/Inches ⇄...
-
<?php $to = "somebody@example.com, somebodyelse@example.com"; $subject = "HTML email"; $message = " <h...
-
document.onkeydown = myKeyDownHandler; function myKeyDownHandler(event){ alert(event.keyCode) }
-
Input array= array("test"=>array("s1"=>array(),"s2"=>array())) foreach(array_keys($free_tim) as ...
No comments:
Post a Comment