It reminds me of college exercises and Facebook Hacker Cup.
PHP Code:
<?php
$array = array(-77, 55, 22, 0, 2, 155);
sort($array);
$i = $j = $k = 0;
$number = 100;
$found = false;
foreach($array AS $i => $value)
{
$j = $i + 1;
$k = count($array) - 1;
while ($j < $k)
{
$sum = $array[$i] + $array[$j] + $array[$k];
if ($sum > $number)
{
$k--;
}
else if ($sum < $number)
{
$j++;
}
else
{
$found = true;
break 2;
}
}
}
if ($found)
{
echo "It is possible. The numbers are: " . $array[$i] . ", " . $array[$j] . ", " . $array[$k];
}
else
{
echo "It is not possible.";
}