Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Would it be possible to incorporate a str_replace method with a regular expression, designed to catch url strings in a simple html < textfield > input type?

I'm considering something simple like a tip for the user to set it up as follows:

This is some text and click this link here.

Obviously the word "here" is a href to the url before it (or after it, if that makes a difference). The text input is drawn from a MySQL db.

I believe the start of my solution is something along the lines of:

$regex = '';
$pg = $row['pg'];
$pg = str_replace('{regex goes here}', $pg);

But I know things are missing. And then I would just output the $pg paragraph.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
547 views
Welcome To Ask or Share your Answers For Others

1 Answer

Check out preg_replace here, this is what you are lookin for.

// From the documentation.
preg_replace($regularExpression, $replacement, $subject); 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...