按照RATE修改变量或数组单元的值
<?php /** * 按照RATE修改变量或数组单元的值 * * @author yearnfar */ define('RATE', 0.5); function affectNumber(&$number1, &$number2=0, &$number3=0, &$number4=0, &$number5=0) { $count = func_num_args(); if ($count<1 || $count>5) { exit("param error!"); } for ($i=1; $i<=$count; $i++) { $varname = 'number'.$i; $$varname = $$varname * RATE; } } // 例子1 $a = 80; $b = 90; $c = 100; affectNumber($a, $b, $c); echo $a."rn"; echo $b."rn"; echo $c."rn"; function affectArray(&$arr) { $args = func_get_args(); if (empty($args)) { exit("param error!"); } array_shift($args); foreach ($arr as $key => $value) { if (empty($args) || in_array($key, $args)) { $arr[$key] = $value * RATE; } } } //例子2 $arr = array(80, 90, 100); affectArray($arr, 0, 2); print_r($arr);
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
1 months agoByDDD
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Assassin's Creed Shadows: Seashell Riddle Solution
1 weeks agoByDDD
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 English version
Recommended: Win version, supports code prompts!

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools