$$wname
w变量名为变量,减少重复代码。
1 <?php 2 function w_w($w_arr, $link) 3 { 4 $wres = true; 5 foreach ($w_arr AS $w) { 6 $wname = 'w' . $w; 7 js_pure_alert($wname); 8 if (!empty($$wname)) { 9 $sql = 'UPDATE asin_email SET email_type=' . $w . ' WHERE id IN(' . substr($$wname, 0, strlen($$wname) - 1) . ')'; 10 if (!mysqli_query($link, $sql)) $wres = false; 11 } 12 } 13 return $wres; 14 }