Remove duplicate elements from an array in PHP without using built-in functions