javascript - How to turn an array into a negative number in php
欧阳克
欧阳克 2017-06-12 09:22:42
0
3
831

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?

欧阳克
欧阳克

温故而知新,可以为师矣。 博客:www.ouyangke.com

reply all(3)
黄舟

$arr1 = array(1,2,3);
$arr2 = array();
foreach($arr1 as $v){

  $arr2[] = -$v;

}

曾经蜡笔没有小新
$a = array(1, 2, 3, 4, 5);
$a = array_map(function ($item) {
    return $item<0?$item:-$item;
}, $a);
过去多啦不再A梦

Loop, take negative value and save to database

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template