About PHP regular expressions $ lrn, $ lid); if $ lid gets multiple values, what should I do? Thank you for choosing if & nbsp; ($ lid]) & nbsp ;{& lt; option & nbsp; value & lt ;? Php & nbsp; echo & nbsp; $ row [id]? & PHP regular expressions
$ Lid = str_replace ("\ r \ n", "", $ lid );
If $ lid gets more than one, what should I do? Thank you!
If ($ lid = intval ($ row ['id']) {
} Else {
?>
------ Solution --------------------
If multiple $ lids are obtained, convert $ lid explode into an array, and then loop through the array to gradually compare:
Code:
$ Lid = str_replace ("\ r \ n", "", $ lid );
// Assume that multiple IDs are separated by commas (,).
// Combine $ lid into an array
$ Pai_arr = explode (',', $ lid );
If (! Empty ($ pai_arr )){
// Loop array
Foreach ($ pai_arr as $ lid ){
// Original comparison process
If ($ lid = intval ($ row ['id']) {
} Else {
?>
}
}
------ Solution --------------------
$ Arr = explode (',', $ lid );
If (in_array (intval ($ row ['id']), $ arr ){
} Else {
?>