//declare array variable $data['direct_sponsor_bonus_vals']=array('package_size'=>''); // insert element to array for ($x = 0; $x <= 10; $x++) { $data['direct_sponsor_bonus_vals']=array('package_size'=>$x); } //show output foreach($direct_sponsor_bonus_vals As $key => $value ) { echo $value . ","; }
I have tried replace <pre> $data['direct_sponsor_bonus_vals']=array('package_size'=>$x);
$data['direct_sponsor_bonus_vals']['package_size'][] = $x;
$array = null; for ($x = 0; $x <= 10; $x++) { $array[]= array('package_size'=>$x); } //to send above array to view just do $data['direct_sponsor_bonus_vals'] = $array;
foreach($direct_sponsor_bonus_vals as $value) { echo $value['package_size'] . ","; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)