Skip to content

Instantly share code, notes, and snippets.

@s0enke
Created January 3, 2015 12:32
Show Gist options
  • Save s0enke/37e0e93d833af1a004a1 to your computer and use it in GitHub Desktop.
Save s0enke/37e0e93d833af1a004a1 to your computer and use it in GitHub Desktop.
PHP Equality Table
<?php
$values = array(
'true' => true,
'false' => false,
'1' => 1,
'0' => 0,
'-1' => -1,
'"true"' => "true",
'"false"' => "false",
'"1"' => "1",
'"0"' => "0",
'"-1"' => "-1",
'""' => "",
'null' => null,
'"null"' => "null",
'[]' => array(),
'{}' => new stdClass(),
'[[]]' => array(array()),
'[0]' => array(0),
'[1]' => array(1),
);
?>
<html>
<style>
body {
font-family: Courier new;
}
table {
font-size: 10px;
}
th > div {
vertical-align: center;
width: 20px;
transform: rotate(90deg);
}
th {
width: 20px;
height: 60px;
padding: 0px;
margin: 0px;
}
td {
padding: 0px;
margin: 0px;
}
.side {
width: 60px;
font-weight: bold;
text-align: center;
}
td.equals {
border: 1px solid black;
background-color: #5bbe5b;
}
td.notequals {
border: 1px solid grey;
background-color: white;
}
td.comp {
width: 20px;
height: 20px;
}
</style>
<body style="background-color: #eeeeee">
<table>
<tr>
<th class="side">&nbsp;</th>
<?php
foreach ($values as $valuePretty => $value) {
?>
<th><div><?php echo htmlspecialchars($valuePretty); ?></div></th>
<?php
}
?>
</tr>
<?php
foreach ($values as $valueYPretty => $valueY) {
?>
<tr>
<td class="side"><?php echo htmlspecialchars($valueYPretty); ?></td>
<?php
foreach ($values as $valueX) {
?>
<td class="comp <?php echo ($valueY == $valueX ? 'equals' : 'notequals'); ?>">&nbsp;</td>
<?php
}
?>
</tr>
<?php
}
?>
</table>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment