Question about ereg_replace and urlencode...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello!

i am trying to make links clickable on a page. I would like to
urlencode the URL so that it is well passed to a redirect.php file,
which would do somethings and then also do a meta http refresh

I am trying to use a function like the following, but it doesn't work.
I would like to apply urlencode on the link that is there in $str, so
that i have the link to redirect.php?url=<<urlencoded str>>

With the following, "1" gets hardcoded in my link! How do i urlencode it please?

Any thoughts would help

Regards

Venky

<?php

$str='blah blah
http://www.someserver.com/indexn12.asp?main_variable=EDITS&amp;file_name=edit3%2Etxt&amp;counter_img=3
blah blah';


function b_make_clickable ($str) {
  $str = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)',
'<a href="http://www.myserver.com/redirect.php?url=' . urlencode(1) .
'" target="_blank">\1</a>', $str);
  $str = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)',
'\1<a href="http://www.myserver.com/redirect.php?url=http://' .
urlencode(2) . '" target="_blank">\2</a>', $str);
  $str = eregi_replace('([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})','<a
href="mailto:\1";>\1</a>', $str);
  return $str;
}

?>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux