I have gone through all of the other posts on here that I can find regarding this warning, but I cannot seem to correct it. Warning is PHP Warning: in_array() expects parameter 2 to be array, string given in...
.
The code:
$my_teachers = $student->my_teachers;
if (in_array($teacher_email, $my_teachers)) {
I understand that $my_teachers needs to be an array, but it is as far as I can tell. The value is created by creating an array, pushing the teacher's emails into the array, and saving it to MySQL. The MySQL database row shows as
a:2:{i:1;s:16:"teacheremail1@gmail.com";i:2;s:18:"teacheremail2@gmail.com";}
Is this actually storing as a String and I'm not realizing it? Either way, how do I get rid of the warning? The code still gives me the intended results, but the warning is filling up my error_log.
serialize()
string. Useunserialize($string)
to transform back into array. – Felippe Duarte Dec 16 '20 at 15:33