小编Ac0*_*Ac0的帖子

Add previous value on array - PHP

I'm trying to figure out how to make an array add the value of the previous array, so far, looking at the PHP manual I got how to add a single value for each position of the array, but I don't understand how can I add the previous value to the actual value. That's what i got checking the manual:

<!DOCTYPE html>
<head>
</head>
    <body>
        <?php
           foreach (array(422, 322, -52323, 7452) as &$val) {
            $val = $val + 2;
            
                echo …
Run Code Online (Sandbox Code Playgroud)

php arrays foreach

0
推荐指数
1
解决办法
930
查看次数

标签 统计

arrays ×1

foreach ×1

php ×1