Terminé

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.

Compétences : PHP

en voir plus : php function for, php function , php ar, my ar, function, fotos, check input function php, function check php, word find function, simple print function, php echo print, php http https, simple find replace php, php return, word find replace, string function, complex php, php simple ajax calculator function, php word com, simple text replace

Concernant l'employeur :
( 12 commentaires ) Buenos Aires, Argentina

Nº du projet : #1734361

Décerné à:

dtbang

Can be done within 1 hour.

%selectedBids___i_sum_sub_7% %project_currencyDetails_sign_sub_8% USD en 0 jours
(26 Commentaires)
4.8

10 freelance font une offre moyenne de $64 pour ce travail

solutionswithus

please provide a chance to work with [login to view URL] have developed a lot site as : [login to view URL] [login to view URL] [login to view URL] Hope for good resp Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(11 Commentaires)
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:- [login to view URL]://[login to view URL] (Zend) [login to view URL]://[login to view URL] Plus

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 5 jours
(108 Commentaires)
7.1
Max01

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

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 0 jours
(99 Commentaires)
5.8
JonnyTheDreamer

Hi. Ready to help.

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 2 jours
(33 Commentaires)
5.6
zavakid

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

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(10 Commentaires)
3.9
avj1989

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

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 2 jours
(7 Commentaires)
3.1
brianbradley

This will be a quick job.

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(1 Évaluation)
1.3
pzycodez

Ready to start now. Please check PMB.

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 0 jours
(0 Commentaires)
0.0
LokkiUA

It'll be very quick job

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 0 jours
(0 Commentaires)
0.0