How to ramdom 2 adsense accounts?

Discussion in 'PHP' started by metros, Nov 11, 2007.

  1. #1
    I am looking for a code so me and my partner can share adsense, since adsense don't allow 2 accounts.. :rolleyes:
     
    metros, Nov 11, 2007 IP
  2. liam1412

    liam1412 Active Member

    Messages:
    387
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #2
    You could always just set up channels


    or just use php


    $oddarray = array(1,3,5,7,9);
    
    $rand = rand(0,10);
    
    if(in_array($rand, $oddarray)){
    
      $adsenseid = 'insertidhere';
    
    } else {
    
      $adsenseid = 'insertidhere';
    
    }
    PHP:
    If you have this query in your header file and then when you copy the code from google you can just change the bit that says publisherid to <?php echo $adsenseid; ?> and you have a 50/50 chance of which publisher id will be used.
     
    liam1412, Nov 11, 2007 IP
  3. metros

    metros Notable Member

    Messages:
    3,978
    Likes Received:
    373
    Best Answers:
    0
    Trophy Points:
    245
    #3
    Thanks for the fast replay and the help :)
     
    metros, Nov 11, 2007 IP
  4. metros

    metros Notable Member

    Messages:
    3,978
    Likes Received:
    373
    Best Answers:
    0
    Trophy Points:
    245
    #4
    hi again,

    after i did it's give me:
     
    metros, Nov 11, 2007 IP
  5. liam1412

    liam1412 Active Member

    Messages:
    387
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #5
    Sorry yeah I forgot the adsense code was a JS

    What you would need to do in this case is copy the full adsense script for each account and put that in the if statement.

    So in pseudo code it would be




    <?php
    if(in_array($rand,$oddarray)){
    ?>
    
     full adsense script from account a
    
    <?php
    
    } else {
    
    ?>
     full adsense script from account b
    <?php
    
    }
    
    ?>
    PHP:
     
    liam1412, Nov 11, 2007 IP
  6. jonimontana

    jonimontana Well-Known Member

    Messages:
    262
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    108
    #6
    Why?
    he can also do :

     
    jonimontana, Nov 11, 2007 IP