GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   preg_match vs parse_url which is faster? (https://gfy.com/showthread.php?t=977029)

fris 07-08-2010 06:16 AM

preg_match vs parse_url which is faster?
 
Im trying to remap all urls with a refcode

Code:

<?php


$url = 'http://themeforest.net/item/simple-mobile-template/112089';

function refcode($url) {
    $sites = array('themeforest.net','activeden.net','audiojungle.net','videohive.net','graphicriver.net','3docean.net','codecanyon.net');
    $refcode = '/?ref=chrismccoy';
    $parsed = parse_url($url);
    if (in_array($parsed['host'],$sites)) {
        return $url . $refcode;
    }
}

echo refcode($url);

?>

or

Code:

<?

$st = "/?ref=lorem";
$url = "http://themeforest.net/item/studio960-wordpress-by-cudazi/111595";
$link = preg_replace('/.*?<a [^>]*href[^>]*'.preg_quote($url,"/").'[^>]*>(.*?)<\/a>.*/is','\1',$url.$st);

echo preg_quote($url);

?>

sample #2 will scan for all links (will be in the body of a blog post), which I need it to do.

anyone got other suggestions?

:thumbsup


All times are GMT -7. The time now is 02:05 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123