Actually, you are incorrect. Not sure why you have to be so stuck up but anyways I'll explain it to you.
I think the main point of this is for him to find in a string all the websites that are actually websites. You are using preg_replace(); however, there is more than one way of doing something. If you actually view your code it doesnt fully wrap the code. On another note if you add this to the end of string "team.error", well it looks like we have a new type of website.
What my code does is actually checks to see if the website is REAL and FULLY wraps the code in html. If he doesnt want the html and just the string well that's easy to do.
Why dont you look and test the code before stating:

Originally Posted by
traq
@Crazykld69, I am not sure what you are trying to contribute with this post. The code you offered doesn't seem to address any of the OP's questions.
If you do have something to contribute, please edit your post to more clearly explain.
I find that uttly rude.
Because the only reason i am here is to help people out and contribute.
Not sure how my code doesnt help him out but it
1. get the string and checks if there can be anything in there that contains websites
2. if it is an actual website it FULLY and CORRECTLY wraps the string in html
3. Doesn't mark fake websites as websites.
Edited it a little:
PHP Code:
$string = 'Looking for marketers who want to work. Ready to change your life? Trevo offers one product - an all natural, vegan, kosher nutritional supplement with 174 nutraceuticals. Visit SoCal.trevobuilder.com for product info & to purchase. Find me on facebook at Trevo SoCal or @TrevoSoCal on twitter. Low start up, cost covers first 3 bottles or larger packages available. No registration fees. Start making money this week! Visit trevocorporate.com/coach/sjahr to register on the Presidential Elite team.error';
$new_string = '';
$string_explode = explode(' ',$string);
foreach($string_explode as $key){
$check = strpos($key,'.') !== false ? weblink($key):$key.' ';
echo $check;
}
function weblink($test){
$ch = curl_init();
$www = preg_match('/www./',$test)?'':'www.'.$test;
curl_setopt($ch, CURLOPT_URL, $www);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
$data = curl_exec($ch);
$info = curl_getinfo($ch);
$code = $info['http_code'];
curl_close($ch);
$good_array = array(100,101,200,201,202,203,206,300,301,302,304);
if(in_array($code,$good_array)){
$add = preg_match('/http:\/\//',$test)?'':'http://';
return '<a href="'.$add.$test.'">'.$test.'</a> ';
}else{
return $test.' ';
}
}
thanks
-DW
Bookmarks