Search code examples
phpvariableshyperlinkappendvbulletin

append a variable after a link in php


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.


Solution

  • 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";
    ?>