I believe the line
if ($dayfrac < 0) $dayfrac += 1;
is in error. If you are before noon, you don't want to refer to the same time one day later, but instead you want to specify a time before noon, i.e. subtract from the julian date which represents noon.
Removing that line, your example date corresponds to the one computed using http://www.imcce.fr/en/grandpublic/temps/jour_julien.php, namely 2456536.9166666665. The resulting
$el = 67.775028608168
$az = 54.515316112281
looks pretty good to me. In particular, it agrees with the R run
elevation = 67.77503
azimuth = 54.51532
and also with what Stellarium says (although I quoted this incorrectly in a comment above):
Alt = 67°46'30" = 67.775
Az = 54°30'60" = 45.5167
It also (almost) agrees with sunearthtools.com, so I guess you made a mistake when first entering the data there:
So I'd say that solves the problem.