PHP Project Euler Problem 34

Solution for the Project Euler Problem 34: "145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145. Find the sum of all numbers which are equal to the sum of the factorial of their digits. Note: as 1! = 1 and 2! = 2 are not sums they are not included."

<?php
$megasum = 0;

for ($i = 3; $i <= 500000; $i++)
{
	$parts = str_split($i);
	$sum = 0;
	
	foreach($parts as $key => $show) {
		$result = 1;
		for ($z = 1; $z <= $show; $z++) {
			$result = $z * $result;
		}
		$sum += $result;
	}
	if ($sum == $i) {
		$megasum += $i;
	}
}
echo $megasum;
?>