How to rotating element id

Discussion in 'PHP' started by josephray, Apr 13, 2011.

  1. #1
    Hi,

    I would like to know how to rotate an element ID using php.

    I have an element ID as follow

    <div id="adsense1">...</div>

    I want to rotate it so that it can be
    <div id="adsense1">, <div id="adsense2">, <div id="adsense3">, and so on.

    I have tried these but fail :
    - <div id="adsense<?php .rand(1,5); ?>">
    - <div id=<?php 'adsense' . rand(1,5); ?>>

    Is it possible to rotate the id in php & how to do that?

    Thanks for your help.
    Joseph
     
    josephray, Apr 13, 2011 IP
  2. Sepehr

    Sepehr Peon

    Messages:
    568
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try this:

    <div id=<?php echo '"adsense' . rand(1,5).'"'; ?>>
     
    Sepehr, Apr 14, 2011 IP
  3. josephray

    josephray Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks.
    I have solved it.
     
    josephray, Apr 15, 2011 IP