1
$example="this is an example of [link](http://webpage.com)"

this is an example of link

how to do make this happen using php functions?

many thanks

2 Answers 2

2

Here's a simple regex solution:

$example="this is an example of [link](http://webpage.com)";
echo preg_replace("/\[(.+?)\]\((.+?)\)/", "<a href=\"$2\">$1</a>", $example);
Sign up to request clarification or add additional context in comments.

Comments

0

That's Markdown syntax. You can get an implementation for PHP from here.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.