3v4l.org

run code in 300+ PHP versions simultaneously
<?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);

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
161.01 ms | 2528 KiB | 14 Q