如何获取父项是数组中项的所有结果

I have an array that consists names of parents ,I want to get all the results where any of the name is a parent.Here is my code.I am not able to get the list of names where parent is equal to the names in district array.

Here is my complete code.

<?php
$functionname = 'core_course_get_categories';
$username = array('key' => 'name', 'value' => '2016');
$params = array('criteria' => array($username));
$server_url = 'localhost/moodle' . '/webservice/rest/server.php' . '?wstoken=' . '9cdaccf3a7ad2f0f94922ccfd02559f4' . '&wsfunction=' . $functionname;
$rest_format = 'json';
require_once('curl.inc');
$curl = new curl;
$rest_format = ($rest_format == 'json') ? '&moodlewsrestformat=' . $rest_format : '';

$resp = $curl->post($server_url . $rest_format, $params);
$res = json_decode($resp);
// drupal_set_message('<pre>'. dpm($res) .'</pre>');
$district = array();
$Ctsc = array();
$School = array();
$Grade = array();
$parent = array();

foreach ($res as $r) {
    $a = $r->parent;
    $c = $r->name;
    if ($a == 0) {
        $b = $r->id;
        var_export($b);
    }
}
foreach ($res as $r) {

    if ($r->parent == $b) {
        //$dist=$r->name;
        $district[] = $r->name;
    }
}    

$Ctsc[] = $r->description;
$School[] = $r->sortorder;
$Grade[] = $r->depth;
foreach ($res as $r) {        
    $q = $r->name;
    if (in_array($q['parent'], $district)) {
        $Ctsc[] = $q->name;
        dpm($Ctsc);
    }
    if ($Ctsc['parent'] == $district) {

        dpm($Ctsc);
    }
}

Usage of in_array() is wrong.

Instead of

if(in_array($q['parent'] == $district)){ ... }

use

if(in_array($q['parent'], $district)){ ... }