English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i have a column with a user's profile, i would like to extract hyperlinks from that profile.

example: user="bob", profile="this is my profile, look at http://google.com and http://yahoo.com and my myspace at http://myspace.com/users/mlkgj"

should return:
user | link
"bob" "http://google.com"
"bob" "http://yahoo.com"
"bob" "http://myspace.com/users/mlkgj"

2006-07-02 04:29:09 · 1 answers · asked by Anonymous in Computers & Internet Programming & Design

1 answers

I don't know that mySQL has those capabilities, but php that will mimic it is:

$SQL = "SELECT user,profile FROM table";
//run your select

while($rs=fetchRow()){
//change that function however your database abstraction works
$name = $rs['user'];
$regExp="/http://.*\w/";
$matches=array();
preg_match_all($regExp,$rs['profile'],$matches);
foreach($matches as $url){
echo "$name $url
";
}
}
?>

2006-07-02 04:39:10 · answer #1 · answered by John J 6 · 2 0

fedest.com, questions and answers