jeudi 25 août 2016

Search value "in_array"

I have this array

Array
(
    [result] => Array
        (
            [status] => nok
            [reason] => Character not found.
        )

    [code] => 404
    [content_type] => application/json;charset=utf-8
)

I want to check the [status], if it is "nok" it should appear "Match found".

My code:

$info = $r['result']['status'];
if (in_array("nok", $info))
  {
  echo "Match found";
  }
else
  {
  echo "Match not found";
  }
?>

Aucun commentaire:

Enregistrer un commentaire