$className = "Class B: Wednesday 6pm";
// $studentArray is multidimensional array with student info
foreach($studentArray as $student) {
echo array_search($className,$student);
}
// Contents of $student is
Array
(
[Groups] => 187,267
[Birthday] => DateTime Object
(
[date] => 1981-02-04 00:00:00.000000
[timezone_type] => 3
[timezone] => UTC
)
[_IGTestScore] => 0
[Email] => [email protected]
[_IGClass1] => Class B: Wednesday 6pm
[_IGAttendedClass1] => DateTime Object
(
[date] => 2016-02-17 00:00:00.000000
[timezone_type] => 3
[timezone] => UTC
)
[FirstName] => Joe
[Id] => 3
[LastName] => Schmoe
)
The output of that is:
_IGTestScore
If I do a var_dump on $className and $student['_IGClass1] I get:
string(22) "Class B: Wednesday 6pm"
string(22) "Class B: Wednesday 6pm"
Never had an issue with array_search before, but this has been driving me crazy, and can't seem to figure out what is going on here. It seems that any string search is coming out the same. But if I do a search for an integer, like 3, it will pull out "Id" correctly.
UPDATE - whole multi-dimensional array
Array
(
[0] => Array
(
[Groups] => 187,267
[Birthday] => DateTime Object
(
[date] => 1981-02-04 00:00:00.000000
[timezone_type] => 3
[timezone] => UTC
)
[_IGTestScore] => 0
[Email] => [email protected]
[_IGClass1] => Class B: Wednesday 6pm
[_IGAttendedClass1] => DateTime Object
(
[date] => 2016-02-17 00:00:00.000000
[timezone_type] => 3
[timezone] => UTC
)
[FirstName] => Joe
[Id] => 3
[LastName] => Schmoe
)
)
Class B: Wednesday 6pmvalue in the array may have a space in the end, like this:Class B: Wednesday 6pm. And this might be the issue.var_dump($student['_IGTestScore']), not_IGClass1... ッ