Skip to content

Instantly share code, notes, and snippets.

@kopiro
Last active December 9, 2015 21:18
Show Gist options
  • Select an option

  • Save kopiro/4329461 to your computer and use it in GitHub Desktop.

Select an option

Save kopiro/4329461 to your computer and use it in GitHub Desktop.
Sort in "match" based
<?php
usort($elements, function($a, $b)
{
$pattern = "#tag1|tag2|tag3|tag4#i";
preg_match_all($pattern, $a, $_a);
preg_match_all($pattern, $b, $_b);
return (count($_a[0])<count($_b[0]));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment