3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_set_arr( $hold=null, $use=null, $action_name=null, $action_update=null ){ $set_arr = [ [ 'key'=>'a', 'hold'=>['cat'], 'use'=>['mew'], 'action_name'=>'honk', 'action_update'=>['animal','cute'] ], [ 'key'=>'b', 'hold'=>['dog'], 'use'=>['bow'], 'action_name'=>'bark', 'action_update'=>['animal','cool'] ], [ 'key'=>'c', 'hold'=>['cow'], 'use'=>['moo'] ], ]; // 引数をもとに一致する行の配列を返す $result = []; foreach( $set_arr as $set ){ if( $hold==null ? false : $hold['hold']==$set['hold'] || $use==null ? false : $use['use']==$set['use'] || $action_name==null ? false : $action_name['action_name']==$set['action_name'] || $action_update==null ? false : $action_update['action_update']==$set['action_update'] ){ $result[] = $set; } } return $result; } $args = ['hold'=>['cat']]; $result = get_set_arr( $args ); var_dump( $result );
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Fatal error: Unparenthesized `a ? b : c ? d : e` is not supported. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)` in /in/WfVEu on line 13
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Fatal error: Unparenthesized `a ? b : c ? d : e` is not supported. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)` in /in/WfVEu on line 13
Process exited with code 255.
Output for 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
Deprecated: Unparenthesized `a ? b : c ? d : e` is deprecated. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)` in /in/WfVEu on line 13 Deprecated: Unparenthesized `a ? b : c ? d : e` is deprecated. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)` in /in/WfVEu on line 13 Deprecated: Unparenthesized `a ? b : c ? d : e` is deprecated. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)` in /in/WfVEu on line 13 Notice: Trying to access array offset on value of type null in /in/WfVEu on line 15 Notice: Trying to access array offset on value of type null in /in/WfVEu on line 15 Notice: Trying to access array offset on value of type null in /in/WfVEu on line 15 Notice: Undefined index: action_name in /in/WfVEu on line 15 array(0) { }
Output for 7.3.32, 7.4.26
array(0) { }
Output for 7.1.25 - 7.1.32, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.3.33
Notice: Undefined index: action_name in /in/WfVEu on line 15 array(0) { }

preferences:
166.8 ms | 402 KiB | 176 Q