jeudi 23 avril 2015

Create a second array_rand based on the first

I have a problem with my array_rand. So, I have an .yml like this :

discover:
first:
    image: test1.jpg
second:
    image: test2.jpg
third:
    image: test3.jpg

Now in php I get this images using array_rand like this :

$firstKey   = array_rand($aArray, 1);
$secondKey = array_rand($aArray, 1);

Where $aArray it's an array witch contains arrays from .yml. The problem it's when $firstKey and $secondKey are equal. It's a way to delete the key who was selected by $firstKey before make the second array_rand? I tried with unset:

unset($aArray['first']);

But no results. Help me please. Thx in advance.




Aucun commentaire:

Enregistrer un commentaire