subhra subhra - 9 days ago 7
PHP Question

How to check array value using in_array in PHP

i have an doubt. I want to check the new value is present in existing array which contains json data using PHP

in_array
method. I am explaining my code below.

{"introId":"582aa53755f5ab487614ddc9","introLabelName":"Age","isIntro":"Yes"}


Here i need to check
582aa53755f5ab487614ddc9
is present in the above array or not using PHP. Please help me.

Answer
$json = '{"introId":"582aa53755f5ab487614ddc9","introLabelName":"Age","isIntro":"Yes"}';
$array = json_decode($json, true);
echo in_array('582aa53755f5ab487614ddc9', $array);

DEMO