<?php
$tab=1;/*$_GET['tab'];*/
$id=1111;/*$_GET['id'];*/
include_once('solve.php');
$query="SELECT
user_job.level1,
user_job.tab_level,
job.money_gain,
job.exp_gain,
job.energy_required,
job.name,job.job_id
FROM user_job
RIGHT JOIN job USING(job_id) WHERE job.tab=".$tab." AND user_job.user_id=".$id." LIMIT 0,10";
$result =solve1($query);
while($data=mysql_fetch_array($result))
{
$i=0;
$rows[]=array('name'=>array(
'name_id'=>$data['name'],
'tab_level'=>$data['tab_level']
),
'job_reward'=>array(
'job_money'=>$data['money_gain'],
'job_exp'=>$data['exp_gain'],
'job_energy'=>$data['energy_required']
),
'job_required_items'=>array()
);
echo $data['job_id'];
$q="SELECT job_item.no,job_item.item_name FROM job_item WHERE job_id=".$data['job_id'];
$data_result=solve1($q);
$re=array();
$data_data="";
while($data_data=mysql_fetch_array($data_result))
{
$r=array( 'filename'=>$data_data['item_name'],
'no'=>$data_data['no']
);
array_push($re,$r);
}
//print_r(json_encode($re));
$row['job_required_items']=array_merge($row['job_required_items'],$re);
//echo $data['job_id']."==>".var_dump($re);
//$rows['job_required_items']=$r;
//$rows['']
//$rows[$i]=$rows[$i]+$re;
//array_merge($rows[$i],$re['job_required_items']);
//array_push($rows[$i],re);
//print_r($re);
//$row[]=array('job_required_items'=>array());
//$rows[$i]=$rows[$i]+$re;
$r=array();
$re=array();
//unset($r);
//unset($re['job_required_items']);
//print_r(json_encode($re));
//($rows);
$i++;
}
//print_r($rows);
print_r(json_encode($rows));
?>
how to add one seperate array into associative array?
like i hav ne array $re
and i have associative array required_item
i want to add $re to 'required_item';