compare array values for a if statement php
<p>im having a list of names james,steve,manson,charles in a array and im using the explode function to separate them.</p>

<pre><code> $pieces = explode(",", $full);

foreach ($pieces as $p ){

    $piece[]=$p;
}
</code></pre>

<p>the problem that im having is that i can access the variables as</p>

<pre><code>$piece[0];
$piece[1];
</code></pre>

<p>but the order differs time to time based on the input therefore i cant do a comparison. can someone suggest how to set the values so i can do the comparison as below</p>

<pre><code> if ($piece==='manson'){
//do something;
}else{
//do something
}

 if ($piece==='steve'){
//do something;
}else{
//do something
}
</code></pre>
