Q: How to select Option in php from my array? I'm trying to select the values from the given array.If same value returns in array I need option to be selected.how to do that ?
Html
<select multiple="" class="Designers" style="width: 100px;">            
                          <option value="JOhn">JOhn</option>
                          <option value="JOhn1">JOhn1</option>
                          <option value="JOhn2">JOhn2</option>
                        </select>

PHP
 Array ( [0] => JOhn[1] => JOhn2);
$DesignerGet =  Array ( [0] => JOhn[1] => JOhn2[2] => JOhn2);
$DesinerEdit = explode(',',$DesignerGet);

<?php if('JOhn2' ==  'JOhn2'){ ?>
 <option value="JOhn1">JOhn1</option>
<?php } ?>

Expected Result 
<select multiple="" class="Designers" style="width: 100px;">            
                          <option value="JOhn" selected>JOhn</option>
                          <option value="JOhn1">JOhn1</option>
                          <option value="JOhn2" selected>JOhn2</option>
                        </select>


A: Use array_unique() function before use an array.
$DesinerEdit = array_unique($DesignerGet);

It removes duplicate values and you can use the array as you want.
Refer php manual for this function

A: Try this :   
 $DesignerGet =  Array ( [0] => JOhn[1] => JOhn2[2] => JOhn2);
    foreach($DesinerEdit as $key=>$val)
    {
       $selected = ($val == 'JOhn1')?"selected ='selected' ":'';
       <option value="JOhn1" <?php echo $selected ?>>JOhn1</option> 

    }


A: Try this way..
<?php
    $arra = Array ('JOhn','JOhn2'); 
    $option = Array ('JOhn','JOhn1','JOhn2');
?>

<select multiple class="Designers" style="width: 100px;">            
    <?php foreach($option as $key => $value){?>
        <option value="<?php echo $value;?>" <?php echo (in_array($value,$arra)) ? 'selected' : '';?>><?php echo $value;?></option>
    <?php }?>
</select>

Here I have used in_array function for checking the values if values is within the get array then it'll be selected else not
