Hi,
In perl, I can increment an array member by using this:
$strings{$1}++
what I want to do is assign a value to a dynamic array member ($i will be a variable) and increase in programatically.
is there something similar in php???
thanks in advance!
perl array increment equivalent in php
Moderator: General Moderators
Re: perl array increment equivalent in php
Same in PHP
Wait, daggone font made it hard for me to see those were curly braces. It is the same if you use square brackets.
-Greg
Wait, daggone font made it hard for me to see those were curly braces. It is the same if you use square brackets.
Code: Select all
$arySample = array('key1'=>5, 'key2'=>8, 'key3'=>10);
$strKey = 'key2';
$arySample[$strKey]++;
echo $arySample['key2']; // Outputs 9
-Greg