3v4l.org

run code in 300+ PHP versions simultaneously
<?php $status_key ="status"; $response = '{"error":false,"data":{"id":16420728,"order_id":"5000","mobile_no":"9995088810","amount":20,"balance":46.89,"status":"failure","tnx_id":"","response":"Transaction Failed"}}'; $result = json_decode($response, true); var_dump(findKey($result, $status_key)); function findKey($array, $keySearch) { foreach ($array as $key => $item) { if ($key == $keySearch) { return true; } elseif (is_array($item) && findKey($item, $keySearch)) { return true; } } return false; }
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
bool(true)

preferences:
126.16 ms | 403 KiB | 214 Q