Earlier quoted context omitted.
You want '0' == 0 and ' 0' == 0. But you also get '0' == false array('0' => 'x') == array(false => 'x') ' 0' == true array(' 0' => 'x') != array(true => 'x') which isn't even an equivalence relation. I have to try this or look it up every time I run into it, because it doesn't make any damn sense.
From the documentation: "A key may be either an integer or a string" So your boolean true is converted to the integer 1 and your boolean false is converted to the integer 0. Dump those arrays and you'll see they don't contain boolean keys. Then it's just a simple matter of '0' == 0 and ' 0' != 1. It's all perfectly logical.
> crafted and refined over many centuries to be nonsensical, maddening, and pointless[....] The punishment lay in knowing that you were putting all of that effort into letting a kind of intellectual poison infiltrate your brain to its very roots.