0

I'm returning an array via REST command from Ellucian's Colleague Web API.

With simpler arrays, I've had no issue, this one is more complex. This array is being returned and formatted via php 5.6 on Linux Red Hat server

Here is a sample of the array:

{
"AcademicTerms": [
    {
        "TermId": "1988FA",
        "GradePointAverage": 3,
        "Credits": 12,
        "ContinuingEducationUnits": 0,
        "AcademicCredits": [
            {
                "Id": "142757",
                "CourseId": "2242",
                "StudentId": "9999999",
                "SectionId": 1234567,
                "CourseName": "MCOM-3103",
                "Title": "Mass Media Survey",
                "VerifiedGradeId": "10",
                "VerifiedGradeTimestamp": "1988-12-15T16:58:31Z",
                "FinalGradeId": "10",
                "FinalGradeExpirationDate": null,
                "LastAttendanceDate": null,
                "NeverAttended": null,
                "Credit": 3,
                "GpaCredit": 3,
                "GradePoints": 9,
                "AttemptedCredit": 3,
                "CompletedCredit": 3,
                "ContinuingEducationUnits": 0,
                "Status": "New",
                "StatusDate": "1988-08-29T00:00:00",
                "TermCode": "1988FA",
                "Location": null,
                "MidTermGrades": [],
                "GradingType": "Graded",
                "SectionNumber": "",
                "HasVerifiedGrade": true,
                "AdjustedCredit": 3,
                "IsNonCourse": false,
                "IsCompletedCredit": true,
                "ReplacedStatus": "NotReplaced",
                "ReplacementStatus": "NotReplacement",
                "StartDate": "1988-08-29T00:00:00",
                "EndDate": "1988-12-15T00:00:00",
                "AdjustedGpaCredit": 3,
                "StudentCourseSectionId": null
            }
          ]
       }
    ]
}

I need the value of "SectionID" to see if a student successfully registered in a class. I've tried using in_array, but I don't think I've had to ever do so with an array that goes multiple levels deep.

trf
  • 143
  • 2
  • 14
  • `$array['AcademicTerms'][$i]['AcademicCredits'][$j]['SectionID']` – Barmar Jan 15 '19 at 22:11
  • `in_array` is for looking for a specific value, not getting the value of a specific item. And it's usually used for indexed arrays, not associative arrays. – Barmar Jan 15 '19 at 22:12
  • I'll be returning multiple AcademicCredits values. I want to see if each SectionID value is listed which indicates a successful registration. Thanks Barmar, I'll try your suggestion. – trf Jan 15 '19 at 22:19
  • Loop through the array and collect all the `SectionID` values into another array. Then you can use `array_intersect()` with your list of all the sections you want to check for. – Barmar Jan 15 '19 at 22:42

0 Answers0