Not your standard io.

Toorcon 12, PHP, and Blah

| Comments

I will be going to Toorcon 12 tomorrow. I have never been to a San Diego or Toorcon, so this will be a first. It looks to be a pretty good line up of talks this year. In order to get back on Sunday I have to leave a bit early so I won’t be able to catch all the talks on Sunday.

I was also asked this week to write a few PHP functions. And while I didn’t do so hot on the spot, I did find a good way to accomplish the task. The question was: write a function to return true or false (or print) if two elements in a given array SUM to be 100. The first function is really slow, but more of an answer if all else fails type of approach.

$RandomArray = Array(74,122,103,125,80,29,127,123,35,33,142,91,
$RequestedNum = 100;

function Search1($RandomArray, $RNum){
 while($count < count($RandomArray)){
  $count = 0;
  foreach($RandomArray as $Num){
   if($RandomArray[$count]+$Num == $RNum){
    echo $RandomArray[$count] . " + " . $Num . " = " . $RNum . " : True";
    break 2;
 if(count > count($RandomArray)){
  echo "No match found :  False";

The second one is a bit quicker and uses the built in function in_array();

function Search2($RandomArray, $RNum){
 $SortedArray = $RandomArray;
 foreach($SortedArray as $SA){
  $findNum = $RNum - $SA;
  $Success = in_array($findNum, $SortedArray);
  if($Success == True){
   echo $SA .  " + " . $findNum . " = " . $RNum . " : True";
 if($Success == False){
  echo "No match found :  False";

I’ve been playing around with the idea of an ultra cheap (sub $100) HTPC with XBMC running on it. Most boxes that would be suited for this are > $100. I’m looking around at some devices that might be able to run as a cheap media streaming box for those extra TVs you might have sitting around in your room/basement. Most of my focus has been towards Nettops and Thin Clients. I also found a cool project of someone in England porting it to a beagleboard.

This makes me want to get one and continue or contribute to his work.