Php Get And Remove Element Leetcode