A price including VAT has two components. The actual price, and the VAT amount.
For a 21% rate, divide by 1.21 is correct, what you need to check is how to round/truncate (some people like to call the latter "round to zero", apparently). Check with the accountant responsible for the project on how the calculated VAT amount should be treated.
Once you have that cracked, don't do any more multiplication/division or rounding of any sort. Simple addition/subtraction with the actual official calculated amount of VAT will get you everything you need. Multiplication/division with or without rounding will get you lost, losing pennies/cents here and there and sometimes being "correct" (but only by coincidence).
When receiving invoice amounts, which include VAT calculated by the invoicer, external to your system, there are two general approaches, one of which I now realise you are using.
Although VAT is a standard calculation, there is more than one way that any given company is allowed to do the calculation. This means VAT you are invoiced for may be calculated (the rounding/truncation) differently from the way your accountant wants it done in your system, and that is OK with the VAT people.
What you need to do with the VAT on an invoice is process it as fact, but you do need to verify it is correct, or at least reasonable (the approach you are using).
To verify that invoiced VAT is correct, you need to know how the supplier is calculating their VAT. There are a limited number of ways which are valid, so this is not as complex as it sounds. On your "supplier table" you have a flag/indicator which says how they round. Once you know this, you can verify absolutely that the VAT invoiced to you is correct.
The other way is the tolerance. Personally, I don't like that, but it is how it was done for invoices received at the last place I worked. One hundredth of a currency-unit was the tolerance that was applied.
If you calculate the VAT and round to nearest 100th of a currency-unit you should be able to verify the VAT being charged to you. At that point, again, don't do more multiplication/division/rounding, but use addition/subtraction as appropriate.
I have no clue as to how rounding of decimals works in PHP.
24 / 1.21 = 19.8347 to four decimal places.
= 19.834 to three decimal places (truncation of intermediate result)
If you round the first to two decimal places, manually, you'd get 19.84. If you round the second, you'd get 19.83.
Although different, still within the tolerance. However, if you multiply/divide/round twice, you could be 0.02 out (if your code doesn't happen to coincide with the code of the supplier).