<?php
class Foo { public $bar; }
$foo = new Foo;
$blanks = array(
"string(empty) \"\"" => "",
"string(space) \" \"" => " ",
"bool(false)" => FALSE,
"bool(true)" => TRUE,
"array(empty) {}" => array(),
"NULL" => NULL,
"string(\"zero\") \"0\"" => "0",
"int(0)" => 0,
"float(0.0)" => 0.0,
"object(stdClass)# (empty) {}" => new stdClass,
"public \$bar" => $foo->bar,
"string(null byte) \"\\0\"" => "\0"
);
$headings = array('type', 'if', 'isset', 'empty', 'is_null');
foreach(array($headings, array_keys($blanks)) as $ord => $arr){
foreach($arr as $val){
static $max = 0;
if(strlen($val) > $max){ $max = strlen($val); }
}
${"pad_$ord"} = $max;
}
for($i = 0; $i < count($headings); $i++){
echo str_pad($headings[$i], ${'pad_' . ($i/$i)}), "|";
}
/*
$x = str_pad("TRUE", PAD_1) . " | ";
$y = str_pad("", PAD_1) . " | ";
foreach($arr as $key => $val){
echo str_pad($key, max(array_map('strlen', array_keys($arr)))), " | ";
echo $val ? $x : $y;
echo isset($val) ? $x : $y;
echo empty($val) ? $x : $y;
echo is_null($val) ? $x : $y;
echo "\n";
}
*/
preferences:
52.14 ms | 402 KiB | 5 Q