$vars['dedicatedip'] ='192.146.12.1'; $vars['assignedips'] = '192.168.12.1 192.134.12.1'; //ip與ip之間有換行符隔開(kāi) $arr3 = ''; if(!empty($vars['dedicatedip'])){ $arr =array($vars['dedicatedip']); } if(!empty($vars['assignedips'])){ $arr2 = explode(PHP_EOL,$vars['assignedips']); } if(!empty($arr) && !empty($arr2)){ $arr3 = array_merge($arr,$arr2); }elseif(!empty($arr2)){ $arr3 = $arr2; }elseif(!empty($arr1)){ $arr3 = $arr1; }
php數(shù)組拆分合并優(yōu)化
狐的傳說(shuō)
2018-07-03 09:09:44