La migliore fonte che puoi usare è http://php.net cerchi le funzioni matematiche che ti servono