This should work - but you must have an index StudentIdpresent in the $ rs array, too ...
$data = array(
array("SchoolName" => "Roy", "StudentId" => "1000,1001,1002"),
array("SchoolName" => "MIT", "StudentId" => "2000,2001,2002"),
array("SchoolName" => "Southwestern College", "StudentId" => "3000,3001,3002"),
array("SchoolName" => "National University", "StudentId" => "4000,4001,4002"),
array("SchoolName" => "Western Governors University", "StudentId" => "5000,5001,5002"),
);
$return = array();
foreach($data as $rs){
$return[$rs['SchoolName']] = $rs['StudentId'];
}
print_r($return);
Live demo: http://codepad.org/HesEO4uF
source
share