I can't sleep well with this one problem. I couldn't find other solution. I have tried some functions, but I can't achieve desirable result with those. So one guy told me to use array_walk()
. Yes this function does what I want, but i can't or i don't know how to properly insert it in my code.
My PHP code:
$d=array();
foreach(range(0, 3) as $rs) {
foreach(range(0, 5) as $c){
//here is working php code to generate '$randomRs' by '$rs' and '$c' vars..
$d['rs'.$rs]['c'.$c] = $randomRs;
}
}
Generated JSON output:
{
"rs0":{
"c0":"pl",
"c1":"wd",
"c2":"wd",
"c3":"pl",
"c4":"bl"
},
"rs1":{
"c0":"gr",
"c1":"gr",
"c2":"lk",
"c3":"gr",
"c4":"lk"
}
and so on...
All i need is one simple code to count specific values of that array.
For example: i need to count how many "wd" and "lk" there is in array. Guy told me to use array_walk()
, but i am new with those array's and i really need some advise!