replace bur repeating
my code is to echo all urls after shorting them in POST ... but here it replace all links with last shorten url only >>>> for exampl:::

when i post >>>>
hello ... check those http://stackoverflow.com/bla , http://stackoverflow.com/blabla , http://stackoverflow.com/blablabla

it must give me after shorting them >>>>
hello ... check those http://stackoverflow.com/1 , http://stackoverflow.com/2 , http://stackoverflow.com/3

but here in that code it give me >>>>
hello ... check those http://stackoverflow.com/3 , http://stackoverflow.com/3 , http://stackoverflow.com/3

it repeat last url in all urls ?????


    $urlinput=mysql_real_escape_string($_POST['url']); 
    $pattren='/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)/';;
    preg_match_all( $pattren, $urlinput, $matches);
    foreach($matches[0] as $match) {
     
    $id=rand(10000,99999);
    $shorturl=base_convert($id,20,36);
    $sql = "insert into url values('$id','$match','$shorturl')";
    mysql_query($sql,$con);
    }
    
    $with="<a href=\"http://127.0.0.1/url1/". $shorturl ."\">http://127.0.0.1/". $shorturl ."</a>";
    $html_links = preg_replace('"\b(http://\S+)"',$with , $_POST['url']);
    
    echo $html_links;


help ??
replace bur repeating
===

my code is to echo all urls after shorting them in POST ... but here it replace all links with last shorten url only >>>> for exampl:::

when i post >>>>
hello ... check those http://stackoverflow.com/bla , http://stackoverflow.com/blabla , http://stackoverflow.com/blablabla

it must give me after shorting them >>>>
hello ... check those http://stackoverflow.com/1 , http://stackoverflow.com/2 , http://stackoverflow.com/3

but here in that code it give me >>>>
hello ... check those http://stackoverflow.com/3 , http://stackoverflow.com/3 , http://stackoverflow.com/3

it repeat last url in all urls ?????


    $urlinput=mysql_real_escape_string($_POST['url']); 
    $pattren='/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)/';;
    preg_match_all( $pattren, $urlinput, $matches);
    foreach($matches[0] as $match) {
     
    $id=rand(10000,99999);
    $shorturl=base_convert($id,20,36);
    $sql = "insert into url values('$id','$match','$shorturl')";
    mysql_query($sql,$con);
    }
    
    $with="<a href=\"http://127.0.0.1/url1/". $shorturl ."\">http://127.0.0.1/". $shorturl ."</a>";
    $html_links = preg_replace('"\b(http://\S+)"',$with , $_POST['url']);
    
    echo $html_links;


help ??