How would I get this code to print that I found the drums?


#1



https://www.codecademy.com/courses/web-beginner-en-5YvPF/0/7?curriculum_id=5124ef4c78d510dd89003eb8


The code doesn't print the way I am expecting it to. I want it to say I found the "drums"?


        $instrument = array("drums", "guitars", "basses", "pianos", "synthesizers", "microphones");
        $instSearch = (0 ,5);
        do {
            $instSearch = array_rand(0,5);
            if ($instrument == "drums") {
                echo "<p>You found the {$instrument}!</p>";    
            } else {
                echo "<p>Keep looking.</p>";
            }
        } while ($instrument);
        $beg = "You looked for the ";
        $end = " and found them!";
            echo "<p>{$beg} {$instrument} {$end}}</p>";


#2

@satoprogrammer,

   $instrument = array("drums", "guitars", "basses",
                       "pianos", "synthesizers", "microphones");
    $instSearch = (0 ,5);  <==== ??????
    do {
        $instSearch = array_rand(0,5);   <== wrong CALL of =array_rand()= FUNCTION
        if ($instrument == "drums") {     <== you are =comparing= the Array with "drums" ??
            echo "<p>You found the {$instrument}!</p>";    <== output total Array ????
        } else {
            echo "<p>Keep looking.</p>";
        }
    } while ($instrument);     <== the Array is the =condition= ???
    $beg = "You looked for the ";
    $end = " and found them!";
        echo "<p>{$beg} {$instrument} {$end}}</p>";

== the Book ==
http://php.net/manual/en/function.array-rand.php
http://php.net/manual/en/control-structures.do.while.php
http://php.net/manual/en/function.rand.php

google search
== discussions / opinions ==
**
php array_rand site:stackoverflow.com