Guest User

Untitled

a guest
Jun 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. <?php
  2. header('Content-Type: text/html; charset=utf-8');
  3. $db = mysql_connect('localhost', 'db_name', 'db_pass');
  4. mysql_select_db('db_name');
  5. mysql_set_charset('utf8');
  6. $res = mysql_query("SELECT * FROM product_description WHERE description like '%'");
  7. while($row = mysql_fetch_array($res)){
  8.  
  9. $anchor = strval($row['description']); //Only this string changed!
  10.  
  11. $anchor = preg_replace(
  12. '@\<a\b[^\>]*\>(.*?)\<\/a\b[^\>]*\>@',
  13. '\1',
  14. $anchor
  15. );
  16.  
  17. echo $anchor;
  18.  
  19. }
  20.  
  21.  
  22. mysql_close($db);
  23. ?>
  24.  
  25. <?php
  26. header('Content-Type: text/html; charset=utf-8');
  27. $db = mysql_connect('localhost', 'db_name', 'db_pass');
  28. mysql_select_db('db_name');
  29. mysql_set_charset('utf8');
  30. $res = mysql_query("SELECT * FROM product_description WHERE description like '%'");
  31. while($row = mysql_fetch_array($res)){
  32.  
  33. $anchor = 'Lorem ipsum <a href="http://www.google.es">Google</a> Lorem ipsum <a href="http://www.bing.com">Bing</a>'; //Only this string changed!
  34.  
  35. $anchor = preg_replace(
  36. '@\<a\b[^\>]*\>(.*?)\<\/a\b[^\>]*\>@',
  37. '\1',
  38. $anchor
  39. );
  40.  
  41. echo $anchor;
  42.  
  43. }
  44. mysql_close($db);
  45. ?>
Add Comment
Please, Sign In to add comment