Skip to content

Instantly share code, notes, and snippets.

@solepixel
Forked from anonymous/custom-sort.php
Last active December 15, 2015 16:29
Show Gist options
  • Save solepixel/5289626 to your computer and use it in GitHub Desktop.
Save solepixel/5289626 to your computer and use it in GitHub Desktop.
<?php
$start_section = array();
$my_section = array();
$end_section = array();
$started = false;
foreach ($arr as $item) {
if (strpos($item, '?param=my_val') !== false) {
$my_section[] = $item;
$started = true;
} else {
if(!$started) {
$start_section[] = $item;
} else {
$end_section[] = $item;
}
}
}
$arr = array_merge($start_section, $my_section, $end_section);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment