Skip to content

Commit

Permalink
Fix a bug in array shifting
Browse files Browse the repository at this point in the history
We were using array_unshift on an associative array, which doesn't
work, because the key doesn't get pushed onto the stack. Instead, we
need to engage in a bit of hackery.
  • Loading branch information
waldoj committed Jun 12, 2013
1 parent b7a348a commit 794f61b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions subsection-identifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,11 @@ function parse()
* consistently, despite being comprised of letters that might reasonably be
* identified by another regex.
*/
$pos = array_search($prefix, $prefix_candidates);
$tmp = $prefix_candidates[$pos];
unset($prefix_candidates[$pos]);
array_unshift($prefix_candidates, $tmp);
$tmp = $prefix_candidates[$prefix];
unset($prefix_candidates[$prefix]);
$prefix_candidates = array_reverse($prefix_candidates);
$prefix_candidates[$prefix] = $tmp;
$prefix_candidates = array_reverse($prefix_candidates);

/*
* Now we need to figure out what the entire section number is, only the very end of
Expand Down

0 comments on commit 794f61b

Please sign in to comment.