开发者

Minus value from array value?

开发者 https://www.devze.com 2023-03-20 07:21 出处:网络
I have the following $interests_row[\'coff\'] which dis开发者_开发知识库plays \"23\" for example, is it possible you can minus 1 from an array value? such as...

I have the following

$interests_row['coff']

which dis开发者_开发知识库plays "23" for example, is it possible you can minus 1 from an array value? such as...

 $interests_row['coff' - 1]


You're altering the index value not the value itself. You can do it at least these two ways:

$interests_row['coff'] -= 1; 

or

$interests_row['coff'] = $interests_row['coff'] - 1;


Nope you need to do:

$interests_row['coff'] -1;

If you use a variable as key something like that would be possible but not in your usecase:

$key = 23;
$interests_row[$key -1];

If you want to modify the value the key is referencing to:

$interests_row['coff] = $interests_row['coff] - 1;
$interests_row['coff] = "test";
etc...


Are you trying to subtract from the value $interests_row['coff']?

OK, well just do that then:

$interests_row['coff'] - 1

Depending on the surrounding code, you may want to use parentheses to group the expression:

($interests_row['coff'] - 1)
0

精彩评论

暂无评论...
验证码 换一张
取 消