Skip to content

Instantly share code, notes, and snippets.

@greevex
Created March 30, 2015 12:21
Show Gist options
  • Save greevex/0f515509ba36646fabcb to your computer and use it in GitHub Desktop.
Save greevex/0f515509ba36646fabcb to your computer and use it in GitHub Desktop.
$a = ["151", "1500"];
foreach($a as $item) { echo "Value `{$item}` is " . gettype($item) . PHP_EOL; }
//output: Value `151` is string
//output: Value `1500` is string
sort($a, SORT_REGULAR);
var_dump($a);
//output: array(2) {
//output: [0] =>
//output: string(3) "151"
//output: [1] =>
//output: string(4) "1500"
//output: }
sort($a, SORT_STRING);
var_dump($a);
//output: array(2) {
//output: [0] =>
//output: string(4) "1500"
//output: [1] =>
//output: string(3) "151"
//output: }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment