To expand on gom's comment, SplMinHeap will also take into account the subsequent elements of the array you inserted, if the elements before that are equal.<?php $heap = new SplMinHeap();$heap->insert([0, 10]);$heap->insert([0, 30]);$heap->insert([0, 15]);while (!$heap->isEmpty()) { [$a, $b] = $heap->extract(); echo "a:$a, b:$b\n";}echo "---\n";$heap->insert([0, 10, 100]);$heap->insert([0, 10, 300]);$heap->insert([0, 10, 150]);while (!$heap->isEmpty()) { [$a, $b, $c] = $heap->extract(); echo "a:$a, b:$b, c:$c\n";}?>will output:a:0, b:10a:0, b:15a:0, b:30---a:0, b:10, c:100a:0, b:10, c:150a:0, b:10, c:300