He explains this: first, that he acted thus in order to know Christ, and secondly to obtain Him. In regard to the first he says, Indeed I count everything as loss. This is true, if he had continued to depend on them. What I did formerly, I now regard a loss on account of my desire for a correct understanding of Christ, my Lord: "For I decided to know nothing among you except Jesus Christ and him crucified" (1 Cor. 2:2). Because of the surpassing worth of knowing Christ Jesus my Lord, since this transcends all knowledge. For there is nothing better to be known than the Word of God "in whom are ...hid all the treasures of wisdom and knowledge" (Col. 2:3).
In regard to the second he says, for his sake I have suffered the loss of all things. First, he shows that he scorned the observance of the Law in order to obtain Christ; secondly, how he could obtain Christ: not having a righteousness of my own, based on Law. He says, therefore: I have suffered the loss of all things by regarding them as vile and contemptible, that I may gain Christ, i.e., obtain Him and be united to Him by charity.
Source: Commentary on Philippians