Skip to content

Instantly share code, notes, and snippets.

@taciara
Created April 14, 2020 15:04
Show Gist options
  • Select an option

  • Save taciara/ec13a800f6db13c686dbf70f19548bb9 to your computer and use it in GitHub Desktop.

Select an option

Save taciara/ec13a800f6db13c686dbf70f19548bb9 to your computer and use it in GitHub Desktop.
Texto Randômico. Exemplo simples em php, mas que pode ser aplicado em qualquer situação
<!DOCTYPE html>
<html>
<head>
<title>Texto Randômico</title>
</head>
<body>
<?php
$linkArray = ['link', 'link2', 'link3'];
$textoArray = ['texto 1', 'texto 2', 'texto 3'];
$link = rand( 0, count( $linkArray ) - 1 );
$texto = rand( 0, count( $textoArray ) - 1 );
?>
<h1>Texto Randômico:</h1>
<br><br>
<a href="<?php echo $linkArray[ $link ]; ?>">
<?php echo $textoArray[ $texto ]; ?>
</a>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment