Structuring a combination of 'functions' in a cohesive manner
<p>My application needs to use a bunch of variations of the code below. There are roughly six or seven variations of the code below, but I'm having trouble organizing them.<br>
At first, I created a class and separated them into functions but for some reason all of the functions stopped working. Just glancing over the code below, do you see maybe a good way to organize something like this?</p>

<pre><code>try{
    $fql = "select uid,name,education from user WHERE uid IN (select uid2 from friend where uid1=($user_id))";
    $param  =   array(
        'method'    =&gt; 'fql.query',
        'query'     =&gt; $fql,
        'callback'  =&gt; ''
    );
    $fqlResult   =   $facebook-&gt;api($param);
}
catch(Exception $o){
    d($o);
}

$friends = $fqlResult;
$friends_BA = array();

foreach ($friends as $friend) {
    $isBA = false;
    if (is_array($friend['education'])) {
        foreach ($friend['education'] as $school) {
            if (isset($school['concentration'])) {
                foreach ($school['concentration'] as $concentration) {
                    if (strpos(strtolower($concentration['name']), 'business') !== false) {
                        $friends_BA[] = $friend['name'];
                        continue 3; // skip to the next friend
                    }
                }
            }
        }
    }
}

d($friends_BA);
</code></pre>
