0

I'm trying to append my variable that displays the count after my links, but I already have code I need replacing links to redirect them to a redirect page.

This is my code currently:

$this->post['message'] = str_replace('href="', 'href="./out.php?link=', $this->post['message']);
$this->post['signature'] = str_replace('href="', 'href="./out.php?link=', $this->post['signature']);

So all the links get redirected to out.php

(small additional question how can i make this not effect img href's?)

So back on topic, what I'm trying to do is add $someVariable[value] after my links, also not effecting images.

The variable would show plain text (numbers) and for example the end result would look like:

<a href="./out.php?link=http://google.com">Google</a>(##)

where ## represents $someVariable

DOM confuses me, and I cant think of any other way to do it, so I need some help.

DrCustUmz
  • 378
  • 4
  • 18
  • 1
    There isn't an img href. It's an img src. The easiest, and most reliable, way of doing this is using DOM. If that confuses you, then starting researching and asking specific questions about that. I'm sure there are plenty of examples out there. – Devon Bessemer Mar 24 '16 at 23:27
  • oh thanks for the tremendous amount of help you provided – DrCustUmz Mar 24 '16 at 23:36
  • You want the value of $someVariable[value] to appear as a text after your links? – rvbarreto Mar 24 '16 at 23:42

1 Answers1

1

1

$ur = "./out.php";
$k = str_shuffle("7dfg9bf09cv04e79507e197a1dtdy8j3");
$web = $ur."/?link=".$k;
echo $web;

Here is an example.

2

Escaping quotation marks in PHP

<?php 

$ur = "./out.php";
// $k = $this->post['message'];
$k = "hello";
$web = "/?link=".$k;
$li = "<a href=\"".$ur.$web."\">".$k."</a>(".$k.")";
echo $li."\n";
?>
Community
  • 1
  • 1
GILLZ
  • 59
  • 5