Backend Development

PHP Question - been bugging me for a while :/

Submitted by iloveducks, , Thread ID: 198799

Thread Closed
23-02-2021, 08:30 PM
This post was last modified: 23-02-2021, 08:30 PM by iloveducks
#1
This has been bugging me for a while, the function of it is to allow a user to input an @ to someone's profile, and it hyperlink there.


The user enters their input "@userinput" which will then change to '<a href="userinput"> userinput </a>'.
Any help would be greatly appreciated, my attempts can be seen below.

My attempts.
Code:
preg_match('#(?>\@)(\w*)#', $string, $matches);
foreach($matches as $row){
$string = preg_replace('#(?>\@)(\w*)#', '<a href="'.$row.'"> '. $row . "</a>", $string);
}
Code:
$string = preg_replace('#\@(.*)#', '<b><a href="=$1"=> @$1 </a></b>', $string);

RE: PHP Question - been bugging me for a while :/

OP
This post was last modified: 23-02-2021, 08:30 PM by iloveducks
#2
This has been bugging me for a while, the function of it is to allow a user to input an @ to someone's profile, and it hyperlink there.


The user enters their input "@userinput" which will then change to '<a href="userinput"> userinput </a>'.
Any help would be greatly appreciated, my attempts can be seen below.

My attempts.
Code:
preg_match('#(?>\@)(\w*)#', $string, $matches);
foreach($matches as $row){
$string = preg_replace('#(?>\@)(\w*)#', '<a href="'.$row.'"> '. $row . "</a>", $string);
}
Code:
$string = preg_replace('#\@(.*)#', '<b><a href="=$1"=> @$1 </a></b>', $string);

RE: PHP Question - been bugging me for a while :/

OP
This post was last modified: 23-02-2021, 08:30 PM by iloveducks
#3
This has been bugging me for a while, the function of it is to allow a user to input an @ to someone's profile, and it hyperlink there.


The user enters their input "@userinput" which will then change to '<a href="userinput"> userinput </a>'.
Any help would be greatly appreciated, my attempts can be seen below.

My attempts.
Code:
preg_match('#(?>\@)(\w*)#', $string, $matches);
foreach($matches as $row){
$string = preg_replace('#(?>\@)(\w*)#', '<a href="'.$row.'"> '. $row . "</a>", $string);
}
Code:
$string = preg_replace('#\@(.*)#', '<b><a href="=$1"=> @$1 </a></b>', $string);

Users browsing this thread: 1 Guest(s)