The value assignment of the in_array variable is treated as a value. The value assignment of the in_array variable is treated as a value. for the solution, see the following code: & lt ;? Php // $ meb ['learned'] The database value is dance, street dance, host, instructor $ learn & nbsp ;=& nbsp; explode (',', $ meb ['learned'] the value assignment of the in_array variable is treated as a value. Solution
The value assignment of the in_array variable is treated as a value. Solution
For details, see the following code:
// $ Meb ['learned'] database values: dance, street dance, host, lecturer
$ Learn = explode (',', $ meb ['learned']);
// Echo $ learn [0]. $ learn [1]. $ learn [2]. $ learn [3]. $ learn [4]. $ learn [5];
$ Strp = str_replace (',', '","', $ meb ['learned']);
$ Strp2 = '"'. $ strp .'"';
$ People = array ($ strp2 );
Print_r ($ people );
// The output result is Array ([0] => "dance", "street dance", "host", "lecturer ")
If (in_array ('lecturer ', $ people )){
Echo "Match found ";
}
Else
{
Echo "Match not found ";
}
?>
The output of in_array's judgment result is "Match not found", that is, the lecturer is not included in $ people, probably because it is regarded as a whole. How to optimize the specific solution and code
Share:
------ Solution --------------------
$ Learn = explode (',', $ meb ['learned']);
$ Learn is not the array you need
If (in_array ('lecturer ', $ learn )){
Echo "Match found ";
}
Else
{
Echo "Match not found ";
}