Welcome Guest, Not a member yet? Register   Sign In
change the value of the array
#7

(05-13-2019, 11:20 AM)Wouter60 Wrote: The $z array is being preserved in the foreach loop. Change it to this:
PHP Code:
foreach ($data as $key => $value)
{
 
   $z = array();
 
   
    foreach 
(explode(','$value["income_country"]) as $val)
 
   {
 
       preg_match('#([0-9]+)([A-Z]+)#',$val,$extrack);
 
       $a $extrack[1];
 
       $b $extrack[2];
 
       if (isset($z[$b])) {
 
        $z[$b] += $a;
 
       }
 
       else {
 
        $z[$b] = $a;
 
       }
 
       arsort($z);
 
   }
 
   $data[$key]["income_country"] = $z;


this works thank you very much
Reply


Messages In This Thread
change the value of the array - by DELE - 05-11-2019, 02:57 PM
RE: change the value of the array - by InsiteFX - 05-12-2019, 03:43 AM
RE: change the value of the array - by DELE - 05-12-2019, 07:51 AM
RE: change the value of the array - by DELE - 05-12-2019, 08:32 AM
RE: change the value of the array - by InsiteFX - 05-13-2019, 03:09 AM
RE: change the value of the array - by Wouter60 - 05-13-2019, 11:20 AM
RE: change the value of the array - by DELE - 05-14-2019, 05:38 AM



Theme © iAndrew 2016 - Forum software by © MyBB