Skip to content

Instantly share code, notes, and snippets.

@nixonmedia
Last active April 17, 2018 20:11
Show Gist options
  • Save nixonmedia/82105493d8cbb6b9badf5e3390c0db2f to your computer and use it in GitHub Desktop.
Save nixonmedia/82105493d8cbb6b9badf5e3390c0db2f to your computer and use it in GitHub Desktop.
<?php
function clean($string) {
return str_replace('*', '', $string);
}
function sortMyThings($things) {
uasort($things, function($left, $right) {
$left = strtoupper(clean($left['name']));
$right = strtoupper(clean($right['name']));
if ($left == $right) return 0;
return $left < $right? -1 : 1;
});
return $things;
}
/* My array looks like this ---
Array
(
[0] => Array
(
[manufacturer] => Cheyenne International,LLC
[brand] => Aura
[type] => Glen Box Menthol
[id] => 44
[rid] =>
[title] => Aura Menthol Glen Box
)
[1] => Array
(
[manufacturer] => Cheyenne International,LLC
[brand] => Aura
[type] => Sky Blue Box
[id] => 63
[rid] =>
[title] => Sky Blue Box
)
[2] => Array
(
[manufacturer] => Cheyenne International,LLC
[brand] => Aura
[type] => Radiant Gold Box
[id] => 64
[rid] =>
[title] => Radiant Gold Box
)
[3] => Array
(
[manufacturer] => Cheyenne International,LLC
[brand] => Aura
[type] => Glen Box Menthol
[id] => 8782
[rid] => 3314
[title] => Aura Menthol Glen Box
)
/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment