Equivalent code for XenForo

  • Thread starter Thread starter Deleted member 10469
  • Start date Start date
D

Deleted member 10469

Guest
Hello, what is the equivalent code for XenForo please?

PHP:
<?php
$monTableauDeCouleur = array('#FFFFFF', '#000000');
$maCouleurAuHasard = $monTableauDeCouleur[rand(0, count($monTableauDeCouleur) - 1)];
 
echo $maCouleurAuHasard;
echo 'test';
 
?>

This code shows me nothing. Thank. :)
 
PHP:
<?php
$arrayColors = array('#FFFFFF', '#000000');
$randomColor = $arrayColors[rand(0, count($arrayColors) - 1)];
 
echo $randomColor;
 
?>

:p
 
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?
 
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;
 
?>
 
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 !
 
Back
Top Bottom