PHP 5.4.10 is not available in the Ubuntu repositories for 12.04.
You have two options:
(1) try and find a PPA with a backported version of PHP 5.4.10 (such as ondrej's oldstable PPA)
a) Run this command:
sudo apt-get install python-software-properties
b) Run this command:
sudo add-apt-repository ppa:ondrej/php5-oldstable
sudo apt-get update; sudo apt-get install php5
d) This should allow you to use PHP 5.4.10 (or whatever the most recent "Old Stable PHP" is).
(2) download PHP from source, and compile it.
5.4.10 does not exist in the repositories for any version of Ubuntu, apparently, so you're stuck with these two options for all releases.
(I can try and backport 5.4.10 from Debian if you would like, but it would be in a PPA, so you'd have to trust that I'm not giving you malware, although I wouldn't do that ever.)