//最大堆 $heap = new \SplMaxHeap(); $heap->insert("data1"); $heap->insert("data2"); // echo $heap->extract(); //最小堆 $heap = new \SplMinHeap(); $heap->insert("data1"); // $heap->insert("data2"); echo $heap->extract();