Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Galera,
como eu faço para substituir o valor de um link(href) salvo no banco de dados?
Exemplo:
Tenho este código salvo no banco de dados:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<custom name="opencounter" type="tracking">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body bgcolor="#FFFFFF" style="margin:10px;">
<table width="600" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="45" height="28" bgcolor="#f5f5f5"> </td>
<td width="508" height="28" align="center" bgcolor="#f5f5f5"><span style="font-size:11px;color:#000000;font-family: Arial;"> Caso
não esteja visualizando corretamente esta mensagem, <a style="text-decoration:none;color:#000000;font-weight:bold;" title="esse link" href="%%view_email_url%%" alias="esse link" conversion="false">acesse aqui.</a> </span></td>
<td width="47" height="28" bgcolor="#f5f5f5"> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="45" height="49" bgcolor="#f5f5f5"> </td>
<td width="508" height="49"><a href="[http://linkX](http://linkX)"><img src="img" width="508" height="49" alt="imagem" style="display:block;border: none;" /></a>
</td>Tentei com o str_replace() mas não rolou muito bem.
Meu código hoje está assim:
$html = $html[0]['html_code'];
echo $html;die();
for ($i=0; $i<=(count($dest)-1); $i++){
$linkAntigo = htmlspecialchars($dest[$i]['main_url']);
echo $linkAntigo."<br >";
$html = str_replace('href="'.$linkAntigo.'"',$dest[$i]['new_url'].$i,$html);
}
echo $html;
Alguma luz?
Carregando comentários...