Suppose $M$ is a smooth manifold with boundary, show that there exists a smooth function $f: M \rightarrow [0, \infty)$ such that $\partial M = f^{-1}(0)$.
My attempt is that given a chart $(U_\alpha, \varphi _\alpha)$ of $M$, $U_\alpha$ is diffeomorphic to some open subset of $\mathbb H ^m = \mathbb R^{m-1} \times [0,\infty)$. Then the m-th coordinate function is a smooth function from $U_ \alpha$ to $[0, \infty)$. But I don't know how to do this globally.
Take a collar neighborhood, ie a diffeomorphism $\partial M \times [0,1) \to U \subset M$ where $U$ is a neighborhood of $\partial M$ and this diffeomorphism takes $\partial M \times 0$ identical to the boundary of $M$. Hence after collapsing $M/M-U$ you get actually the cone $C$ over $\partial M$, which has the projection and you define $M \to M/M-U \to [0,1]$ which is onto.