-3

I have to replace any link in string to specify variable. I have a code

$intro = $this->item->introtext;

this code retrun me for example this

<p style="text-align: center;">
<a href="/upload/dzialanosc-spoleczna/Mikolajki-w-Dabiu-2012/MG_0187.jpg">
<img width="700" height="467" alt="" src="/upload/dzialanosc-spoleczna/Mikolajki-w-Dabiu-2012/MG_0187s.jpg">
</a>
</p>

I have to replace this anchor href by own variable (new generated link) for example $link

aelor
  • 10,892
  • 3
  • 32
  • 48

1 Answers1

0

Have you tried something like this...

<p style="text-align: center;">
<a href="<?php
$index = 0;
$link = 'YourLink';
if($index==0){
//default
echo '/upload/dzialanosc-spoleczna/Mikolajki-w-Dabiu-2012/MG_0187.jpg';
}else{
echo $link;
}
?>">
<img width="700" height="467" alt="" src="/upload/dzialanosc-spoleczna/Mikolajki-w-Dabiu-2012/MG_0187s.jpg">
</a>
</p>

I hope that's what you want :-)

YvesHendseth
  • 1,149
  • 1
  • 10
  • 27