Reputation: 851
I have a link that is created by a variable as below:
<div class="pdf-download">
<a href="/images/documents/187/pdf-test.pdf|Download">Download</a>
</div>
This is being created by the following:
<div class="pdf-download">
<a href="/images/documents/<?= $this->item->id; ?>/<?= $pdfdownload ?>">Download</a>
</div>
I need to remove the "Download" from the url that is created by $pdfdownload.
What is the best way to do this?
Upvotes: 0
Views: 94
Reputation: 11
If the |Download
is always at the end,
you can replace $pdfdownload
with preg_replace('/pdfdownload\|$/','',$pdfdownload)
Upvotes: 1
Reputation: 11317
You can just replace '|Download
' with an empty string with str_replace.
<a href="/images/documents/<?= $this->item->id; ?>/<?= str_replace('|Download', '', $pdfdownload) ?>">Download</a>
Upvotes: 2