@ 2014-01-23T21:39:28Z <?php
<?php
function dive(array $map){
$columns = $tokens = array();
foreach($map as $key => $value){
if(is_array($value)){
// check for bool switch
if(array_key_exists(0, $value)){
if($value[0] !== true) continue;
$columns[$key] = $key;
$tokens[$key] = $value[1];
}else{
// if another array recurse
$tmp = dive($value);
$columns = array_merge($columns, array_keys($tmp));
$tokens = array_merge($tokens, array_values($tmp));
}
}else{
if(is_null($value)) continue;
// catch non-null scalars
$columns[$key] = $key;
$tokens[$key] = "?";
}
}
// because $columns will inevitably contain duplicate values, once the
// two arrays are combined, they will collapse/uniquify. #darkcorner
return array_combine($columns, $tokens);
}
call_user_func(function(){
$a = array(
"col1" => "val",
"col2" => "val",
"col3" => "val",
"col4" => "val",
);
$columns = array(
"col1",
"col2",
"col3",
"col4",
);
$tokens = array(
"?",
"?",
"?",
"?",
);
// list($c, $t) = dive($a);
$tmp = dive($a);
$c = array_keys($tmp);
$t = array_values($tmp);
if($columns == $c){ echo "TRUE\n"; }
if($tokens == $t){ echo "TRUE\n"; }
});
call_user_func(function(){
$a = array(
"col1" => "val",
"col2" => null,
"col3" => "val",
"col4" => "val",
);
$columns = array(
"col1",
"col3",
"col4",
);
$tokens = array(
"?",
"?",
"?",
);
// list($c, $t) = dive($a);
$tmp = dive($a);
$c = array_keys($tmp);
$t = array_values($tmp);
if($columns == $c){ echo "TRUE\n"; }
if($tokens == $t){ echo "TRUE\n"; }
});
call_user_func(function(){
$a = array(
"col1" => array(true, "val"),
"col2" => array(true, "val"),
"col3" => array(true, "val"),
"col4" => array(true, "val"),
);
$columns = array(
"col1",
"col2",
"col3",
"col4",
);
$tokens = array(
"val",
"val",
"val",
"val",
);
// list($c, $t) = dive($a);
$tmp = dive($a);
$c = array_keys($tmp);
$t = array_values($tmp);
if($columns == $c){ echo "TRUE\n"; }
if($tokens == $t){ echo "TRUE\n"; }
});
call_user_func(function(){
$a = array(
"col1" => "val",
"col2" => "val",
"col3" => array(true, "val"),
"col4" => array(true, "val"),
);
$columns = array(
"col1",
"col2",
"col3",
"col4",
);
$tokens = array(
"?",
"?",
"val",
"val",
);
// list($c, $t) = dive($a);
$tmp = dive($a);
$c = array_keys($tmp);
$t = array_values($tmp);
if($columns == $c){ echo "TRUE\n"; }
if($tokens == $t){ echo "TRUE\n"; }
});
call_user_func(function(){
$a = array(
"col1" => array(true, "val"),
"col2" => array(true, "val"),
"col3" => "val",
"col4" => "val",
);
$columns = array(
"col1",
"col2",
"col3",
"col4",
);
$tokens = array(
"val",
"val",
"?",
"?",
);
// list($c, $t) = dive($a);
$tmp = dive($a);
$c = array_keys($tmp);
$t = array_values($tmp);
if($columns == $c){ echo "TRUE\n"; }
if($tokens == $t){ echo "TRUE\n"; }
});
call_user_func(function(){
$a = array(
"col1" => "val",
"col2" => array(true, "val"),
"col3" => array(true, "val"),
"col4" => "val",
);
$columns = array(
"col1",
"col2",
"col3",
"col4",
);
$tokens = array(
"?",
"val",
"val",
"?",
);
// list($c, $t) = dive($a);
$tmp = dive($a);
$c = array_keys($tmp);
$t = array_values($tmp);
if($columns == $c){ echo "TRUE\n"; }
if($tokens == $t){ echo "TRUE\n"; }
});
call_user_func(function(){
$a = array(
array("col1" => "val"),
array("col1" => "val"),
array("col1" => "val"),
array("col1" => "val"),
);
$columns = array(
"col1",
);
$tokens = array(
"?",
);
// list($c, $t) = dive($a);
$tmp = dive($a);
$c = array_keys($tmp);
$t = array_values($tmp);
if($columns == $c){ echo "TRUE\n"; }
if($tokens == $t){ echo "TRUE\n"; }
});
call_user_func(function(){
$a = array(
array("col1" => array(true, "val")),
array("col1" => array(true, "val")),
array("col1" => array(true, "val")),
array("col1" => array(true, "val")),
);
$columns = array(
"col1",
);
$tokens = array(
"val",
);
// list($c, $t) = dive($a);
$tmp = dive($a);
$c = array_keys($tmp);
$t = array_values($tmp);
if($columns == $c){ echo "TRUE\n"; }
if($tokens == $t){ echo "TRUE\n"; }
});
call_user_func(function(){
$a = array(
array("col1" => array(true, "val"), "col2" => array(true, "val")),
array("col1" => array(true, "val"), "col2" => array(true, "val")),
array("col1" => array(true, "val"), "col2" => array(true, "val")),
array("col1" => array(true, "val"), "col2" => array(true, "val")),
);
$columns = array(
"col1",
"col2",
);
$tokens = array(
"val",
"val",
);
// list($c, $t) = dive($a);
$tmp = dive($a);
$c = array_keys($tmp);
$t = array_values($tmp);
if($columns == $c){ echo "TRUE\n"; }
if($tokens == $t){ echo "TRUE\n"; }
});
call_user_func(function(){
$a = array(
array("col1" => "val", "col2" => "val"),
array("col1" => "val", "col2" => "val"),
array("col1" => "val", "col2" => "val"),
array("col1" => "val", "col2" => "val"),
);
$columns = array(
"col1",
"col2",
);
$tokens = array(
"?",
"?",
);
// list($c, $t) = dive($a);
$tmp = dive($a);
$c = array_keys($tmp);
$t = array_values($tmp);
if($columns == $c){ echo "TRUE\n"; }
if($tokens == $t){ echo "TRUE\n"; }
});
call_user_func(function(){
$a = array(
array("col1" => "val", "col2" => null),
array("col1" => "val", "col2" => null),
array("col1" => "val", "col2" => null),
array("col1" => "val", "col2" => null),
);
$columns = array(
"col1",
);
$tokens = array(
"?",
);
// list($c, $t) = dive($a);
$tmp = dive($a);
$c = array_keys($tmp);
$t = array_values($tmp);
if($columns == $c){ echo "TRUE\n"; }
if($tokens == $t){ echo "TRUE\n"; }
});
call_user_func(function(){
$a = array(
array("col1" => "val", "col2" => array(true, "val")),
array("col1" => "val", "col2" => array(true, "val")),
array("col1" => "val", "col2" => array(true, "val")),
array("col1" => "val", "col2" => array(true, "val")),
);
$columns = array(
"col1",
"col2",
);
$tokens = array(
"?",
"val",
);
// list($c, $t) = dive($a);
$tmp = dive($a);
$c = array_keys($tmp);
$t = array_values($tmp);
if($columns == $c){ echo "TRUE\n"; }
if($tokens == $t){ echo "TRUE\n"; }
});
call_user_func(function(){
$a = array(
array("col1" => array(true, "val"), "col2" => "val"),
array("col1" => array(true, "val"), "col2" => "val"),
array("col1" => array(true, "val"), "col2" => "val"),
array("col1" => array(true, "val"), "col2" => "val"),
);
$columns = array(
"col1",
"col2",
);
$tokens = array(
"val",
"?",
);
// list($c, $t) = dive($a);
$tmp = dive($a);
$c = array_keys($tmp);
$t = array_values($tmp);
if($columns == $c){ echo "TRUE\n"; }
if($tokens == $t){ echo "TRUE\n"; }
});
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 5.4.24 0.005 0.038 12.38 5.4.23 0.007 0.036 12.37 5.4.22 0.006 0.036 12.37 5.4.21 0.007 0.035 12.37 5.4.20 0.005 0.038 12.37 5.4.19 0.007 0.035 12.36 5.4.18 0.005 0.036 12.36 5.4.17 0.006 0.036 12.37 5.4.16 0.004 0.038 12.36 5.4.15 0.007 0.035 12.36 5.4.14 0.006 0.038 12.05 5.4.13 0.008 0.034 12.03 5.4.12 0.005 0.035 12.00 5.4.11 0.008 0.035 11.99 5.4.10 0.004 0.037 12.00 5.4.9 0.007 0.036 11.99 5.4.8 0.006 0.037 11.99 5.4.7 0.007 0.033 11.99 5.4.6 0.007 0.034 11.99 5.4.5 0.007 0.034 11.99 5.4.4 0.005 0.035 11.98 5.4.3 0.005 0.038 11.97 5.4.2 0.007 0.038 11.97 5.4.1 0.004 0.036 11.98 5.4.0 0.005 0.036 11.47 5.3.28 0.008 0.036 12.71 5.3.27 0.005 0.042 12.72 5.3.26 0.005 0.043 12.72 5.3.25 0.007 0.043 12.72 5.3.24 0.008 0.039 12.72 5.3.23 0.007 0.042 12.71 5.3.22 0.007 0.043 12.68 5.3.21 0.007 0.041 12.68 5.3.20 0.009 0.035 12.68 5.3.19 0.005 0.039 12.68 5.3.18 0.005 0.039 12.67 5.3.17 0.007 0.038 12.67 5.3.16 0.007 0.036 12.67 5.3.15 0.006 0.038 12.67 5.3.14 0.004 0.041 12.66 5.3.13 0.006 0.038 12.65 5.3.12 0.008 0.039 12.66 5.3.11 0.005 0.043 12.66 5.3.10 0.007 0.038 12.12 5.3.9 0.007 0.038 12.08 5.3.8 0.008 0.034 12.07 5.3.7 0.006 0.037 12.08 5.3.6 0.006 0.038 12.06 5.3.5 0.007 0.037 12.00 5.3.4 0.004 0.039 12.00 5.3.3 0.004 0.038 11.94 5.3.2 0.007 0.038 11.71 5.3.1 0.009 0.043 11.67 5.3.0 0.005 0.046 11.66
preferences:dark mode live preview
140.86 ms | 1394 KiB | 7 Q