Q:

Ajax JSON multi array - determing array index contains specified values

I am returning a JSON multi array from PHP via JQuery Ajax, and want to determine which array contains a value in order to access values in that array (likewise for the other arrays - up to three arrays altogethebeing returned.
$.ajax({
type: "POST",
url: "scripts/get_model_imaging_report.php",
data: {
        case_id:caseId,
        level:currentLevel
},
dataType: "json",
success: function(returnedData) {

}
});

PHP;
$case = $_POST['case_id'];
$level = $_POST['level'];

$query = "SELECT * FROM model_image_report WHERE case_fk = '$case' AND level = '$level'";
$result = mysql_query($query, $connection) or die(mysql_error());

$data = array();
while ($row = mysql_fetch_array($result)) {
        $data[] = array(
        'image_report_type' => $row['image_report_type'],
        'subject' => $row['subject'],
        'clinical' =>  $row['clinical'],
        'study_type' =>  $row['study_type'],
        'report' =>  $row['report'],
        'comment' =>  $row['comment'],
        'image' =>  $row['image'],
        'image_annotated' =>  $row['image_annotated']
        );
} 
echo json_encode($data);

The key I need to check is 'image_report_type' and the values can be 'nuclear', 'radiology' and 'ultrasound'.
Then I need to access values in those arrays where 'image_report_type' == 'nuclear' for example.
The JSON array looks like:
[{"image_report_type":"nuclear","subject":"Brain Scan","clinical":"Clinical","study_type":"nuclear image scan.","report":"Report","comment":"Comment","image":"original_image_case_3_level_1_nuclear.jpg","image_annotated":"annotated_image_case_3_level_1_nuclear.png"},{"image_report_type":"ultrasound","subject":"Brain Scan","clinical":"Clinical","study_type":"Ultrasound image scan.","report":"Report","comment":"Comment","image":"original_image_case_3_level_1_nuclear.jpg","image_annotated":"annotated_image_case_3_level_1_nuclear.png"}]

A:

You can accomplish this with the jQuery each function.
function(returnedData) {
  $.each(returnedData, function(i,o) {
      if (o.image_report_type == "nuclear") {
         //Do Something
      }
  });
}

Here is a jsFiddle Demonstrating this technique

