3v4l.org

run code in 300+ PHP versions simultaneously
<?php // 配列を取得してゴール $result = getArr( [ 'datatype'=>'array', 'use'=>['action'] ] ); var_dump( $result ); // $basesから$argsの指定に応じて配列を取得する function getArr( $args ){ $bases = [ [ 'key'=>'follwoers_arr', 'label'=>'フォロワー', 'datatype'=>'arr', 'use'=>['front','action'] ], // ここに追加したい [ 'key'=>'follwoees_arr', 'label'=>'フォロー中', 'datatype'=>'arr', 'use'=>['front','action'] ], // ここに追加したい [ 'key'=>'age', 'label'=>'年齢', 'datatype'=>'str', 'use'=>['profile'] ], ]; // 「カウント情報」を「ここに追加したい」の行に追加したい $row_arr = getArr( [ 'datatype'=>'arr', 'use'=>['action'] ] ); $count_row = []; foreach( $row_arr as $row ){ foreach( $row as $key=>$val ){ if( $key=='key' ){ $key_all = str_replace( '_arr', '_count_all', $val ); $key_week = str_replace( '_arr', '_count_week', $val ); $bases[] = [ 'key'=>$key_all, 'label'=>'全期間', 'datatype'=>'str', 'use'=>['auto'] ]; // カウント情報 $bases[] = [ 'key'=>$key_week, 'label'=>'一週間', 'datatype'=>'str', 'use'=>['auto'] ]; // カウント情報 } } } // 引数$argsと一致する行の配列を返す $result = []; foreach ($bases as $base){ if (isMatch($args, $base)) { $result[] = $base; } } return $result; } // 引数$argsと一致する行の配列を返す function isMatch($args, $set) { foreach ($args as $key => $vals) { if (!array_key_exists($key, $set)) { return false; } if (is_array($vals)) { foreach ($vals as $val) { if (!in_array($val, $set[$key], true)) { return false; } } } else { if ($vals !== $set[$key]) { return false; } } } return true; }
Output for git.master, rfc.property-hooks
Fatal error: Out of memory (allocated 35651584 bytes) (tried to allocate 262144 bytes) in /in/GYLYN on line 18 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.
Output for git.master_jit
Fatal error: Out of memory (allocated 18874368 bytes) (tried to allocate 262144 bytes) in /in/GYLYN on line 18 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
184.93 ms | 406 KiB | 5 Q