Đang Thực Hiện

Simple PHP function

For my website I need a simple PHP function.

DESCRIPTION:

I need for my website a PHP function to replace text. The function will find any URL inside a string variable and then replace the URL with a second string variable.

For example:

function urlReplace($text, $replaceWith)

then...

$text = "Check this website: [url removed, login to view]"

$replaceWith = '<a href="{0}">{0}</a>'

echo urlReplace($text, $replaceWith)

// Will print on screen "Check this website: <a href="[url removed, login to view]">[url removed, login to view]</a>"

The {0} will be replaced by the URL finded.

If the $replaceWith have a {1} then the URL will be passed to another function called transformURL($url) before print it. This second function will be created by ME.

For example:

Imagine that the transformURL it's defined like this:

function transformURL($url) {

return strtoupper($url);

}

...then...

$text = "Check this website: [url removed, login to view]"

$replaceWith = '<a href="{0}">{1}</a>'

echo urlReplace($text, $replaceWith)

// Will print on screen "Check this website: <a href="[url removed, login to view]">HTTPS://[url removed, login to view]</a>"

IMPORTANT INFORMATION:

- The function it's necesary to word in PHP 5.4

- If the input string have more than one URL then all URLs will be replaced.

- The URL may be a simple "[url removed, login to view]" or a complex like "[url removed, login to view]"

- ANY SUGGESTION IT IS WELCOME.

Kỹ năng: PHP

Xem thêm: php ar, my ar, function, fotos, check input function php, function check php, word find function, simple print function, php echo print, simple find replace php, php return, word find replace, string function, complex php, simple text replace, inside php, complex screen, php function check url, text jpg php, simple word find, simple function php wordpress, simple php function, php print information, url jpg php, website function description

Về Bên Thuê:
( 11 nhận xét ) Buenos Aires, Argentina

Mã Dự Án: #1734361

Đã trao cho:

dtbang

Can be done within 1 hour.

$30 USD trong 0 ngày
(26 Đánh Giá)
4.8

10 freelancer đang chào giá trung bình $64 cho công việc này

solutionswithus

please provide a chance to work with you.We have developed a lot site as : http://www.iphone.solutionswithus.in/ http://www.magento.solutionswithus.in/ http://www.property.solutionswithus.in/ Hope for good resp Thêm

$30 USD trong 1 ngày
(11 Đánh Giá)
7.1
dinotech

We are working in web development since last 4 years. Our first aim is reliable to submit quality project on time; Some of the Projects done by us:- 1.http://e-ternity.com.au/ (Zend) 2.http://www.promus.hr/gea_new2/ Thêm

$250 USD trong 5 ngày
(108 Đánh Giá)
7.1
Max01

hi sir i can do it today,gladly waiting to serve you

$30 USD trong 0 ngày
(99 Đánh Giá)
5.8
JonnyTheDreamer

Hi. Ready to help.

$30 USD trong 2 ngày
(33 Đánh Giá)
5.6
zavakid

hi,juanchipehuajo develope PHP 3+ years, will do this job for you. please check my private message :)

$30 USD trong 1 ngày
(10 Đánh Giá)
3.9
avj1989

Can do this very well ASAP. Please have a look to your PM. Thank you

$80 USD trong 2 ngày
(7 Đánh Giá)
3.1
brianbradley

This will be a quick job.

$30 USD trong 1 ngày
(1 Đánh Giá)
1.3
pzycodez

Ready to start now. Please check PMB.

$30 USD trong 0 ngày
(0 Đánh Giá)
0.0
LokkiUA

It'll be very quick job

$100 USD trong 0 ngày
(0 Đánh Giá)
0.0