Your code contains the amount in USD in the first place. You can use the inverse of the original formula, like this:
const bitcoinrate;
function usd_to_btc($usd) {
$btc = $usd * bitcoinrate;
}
Or maybe like the following line of code i found somehwere:
$one_usd_in_btc = https://blockchain.info/tobtc?currency=USD&value=1
$usd_to_btc = $one_usd_in_btc * your_usd