1. I have an array array(1,2,3); I need it to become a negative number when inserting it into the database
2. The front-end input table displays a positive number, and the back-end becomes a negative number before inserting it into the database. How to achieve this?
黄舟2017-06-12 09:24:42
$arr1 = array(1,2,3);
$arr2 = array();
foreach($arr1 as $v){
$arr2[] = -$v;
}
曾经蜡笔没有小新2017-06-12 09:24:42
$a = array(1, 2, 3, 4, 5);
$a = array_map(function ($item) {
return $item<0?$item:-$item;
}, $a);