I am pretty new to QM, I get the basics of Dirac notation. I understand this is the expectation value of an observable in a state $|\psi\rangle$ is given by:
$$\langle\hat A\rangle = \int\limits_{-\infty}^{\infty}\psi^*\hat A \psi\,\mathrm dx.$$
However, I am also given this in my lecture notes labelled "matrix element":
$$\langle\phi|\hat A|\psi\rangle = \int\limits_{-\infty}^{\infty}\phi^*\hat A \psi\,\mathrm dx.$$
My question is what does it mean to take the integral like this? And what is meant by the label "matrix element"? The expectation value integral makes sense to me since we are using the same state vector twice, but here we are using two separate state vectors.