1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Equivalent code for XenForo

Discussion in 'XenForo Development Discussions' started by Zephyr, Sep 18, 2012.

  1. Zephyr

    Zephyr Well-Known Member

    Hello, what is the equivalent code for XenForo please?

    PHP:
    <?php
    $monTableauDeCouleur 
    = array('#FFFFFF''#000000');
    $maCouleurAuHasard $monTableauDeCouleur[rand(0count($monTableauDeCouleur) - 1)];
     
    echo 
    $maCouleurAuHasard;
    echo 
    'test';
     
    ?>
    This code shows me nothing. Thank. :)
     
  2. SchmitzIT

    SchmitzIT Well-Known Member

    Seeing it's French, the code is most likely on strike.

    rimshot
     
  3. Zephyr

    Zephyr Well-Known Member

    PHP:
    <?php
    $arrayColors 
    = array('#FFFFFF''#000000');
    $randomColor $arrayColors[rand(0count($arrayColors) - 1)];
     
    echo 
    $randomColor;
     
    ?>
    :p
     
  4. James

    James Well-Known Member

    You need to provide more information. There's no software-specific code there at all, it's merely a case of:
    a) What's it for?
    b) Where is it going to be displayed?
     
  5. Lawrence

    Lawrence Well-Known Member

    Your code echo's out what you are telling it to, e.g: #000000test

    I take it you want to randomly change the color of the word "test"?

    Code:
    <?php
    $monTableauDeCouleur = array('#FFFFFF', '#000000');
    $maCouleurAuHasard = $monTableauDeCouleur[rand(0, count($monTableauDeCouleur) - 1)];
     
    $colorOutput = '<span style="color: ' . $maCouleurAuHasard . ';">test</span>';
    echo $colorOutput;
     
    ?>
     
    CyclingTribe likes this.
  6. cclaerhout

    cclaerhout Well-Known Member

    If you're testing your code in Xenforo, the echo command might not be displayed. Use var_dump($le_nom_de_ta_variable) or better Zend_Debug::dump($ta_variable). If you're working with a template or a file which is using ajax to display, see the console of Firebug (Firefox). If you're testing a Javascript code (not php this time), use console.log(tavariable) then go to the Firebug console.
    Bon courage !
     

Share This Page