<?php $str = '[ { "type": "youtube" }, { "type": "Picture" }, { "type": "Gallery" } ]'; $arr = json_decode($str, true); $type = array_column($arr, 'type'); $key = array_search('youtube', $type); if($key === false){ $key = array_search('Picture', $type); } Var_dump($key);
You have javascript disabled. You will not be able to edit any code.