Uffo Uffo - 5 months ago 18
PHP Question

How to check if an array value exists?

How can I check if

$something['say']
has the value of
'bla'
or
'omg'
?

$something = array('say' => 'bla', 'say' => 'omg');

Answer

Using if?

if(isset($something['say']) && $something['say'] == 'bla') {
    // do something
}

Btw, you are assigning an value with the key say twice, hence your array will result in an array with only one value.