I want to generate random pairs of elements and have this code:
<?
$myarray1=array('1','2','3');
$myarray2=array('1a','2a','3a');
echo '<p>'.$myarray1[array_rand($myarray1)].'</p>';
echo '<p>'.$myarray2[array_rand($myarray2)].'</p>';
?>
but I get this as a result:
<p>3</p>
<p>2a</p>
or
<p>1</p>
<p>3a</p>
or
<p>2</p>
<p>1a</p>
etc.
and I want to only get certain pairs:
<p>2</p>
<p>2a</p>
or
<p>1</p>
<p>1a</p>
or
<p>3</p>
<p>3a</p>
etc.
how do I achieve that?
Aucun commentaire:
Enregistrer un commentaire