TypeError thrown

implode(): Argument #1 ($pieces) must be of type array, string given