Skip to content

Instantly share code, notes, and snippets.

@hugollm
Last active December 12, 2015 06:59
Show Gist options
  • Save hugollm/4733267 to your computer and use it in GitHub Desktop.
Save hugollm/4733267 to your computer and use it in GitHub Desktop.
php wtf ~ php's (regular) sorting algorithm is totally unpredictable with mixed types
<?php
$array1 = array("a","b","4",5,4,"true","TRUE",true, false, "c", "d");
$array2 = array("a","b","4",5,4,"true","TRUE",true, false, "c");
sort($array1);
sort($array2);
dump($array1);
dump($array2);
function dump($var)
{
echo '<pre><code>';
var_dump($var);
echo '</code></pre>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment