Jump to content

merrging two arrays at specific date if both date matched


swapnil7779

Recommended Posts

Hi, I am merging the two arrays at particular date. If both array have same date then it will merge the array & plot that array on the graph. But problem is that it is merging the array & appending the bar at the start of the bar only, but not at the specific date where the both date are equal. for e.g.

array1 = (18/03/2013 => 10, 20-03-2013 => 6, 21-03-2013 => 10);

array2 = (20-03-2013 => 5);

 

. so it should append the bar at 20-03-2013 but actually it is appending the bar at the start only i.e. 18-03-2013.

plz help me thanks in advance

hear is my code

 

$count = __Select("tbl_call_master","COUNT(DATE(date_time)) AS call_count , DATE(date_time)AS date ","WHERE DATE(date_time) BETWEEN '$from_date' AND '$to_date' GROUP BY DATE(date_time) ");

$get_first_array=array();
$test= array();

while($row = mysql_fetch_array($count))
{

$record1[]= array(
$row['date'],
$row['call_count']
);

}

$wip= __Select("tbl_call_master","COUNT(DATE(date_time)) AS call_count , DATE(date_time) AS date ","WHERE status= 'WIP' AND DATE(date_time) BETWEEN '$from_date' AND '$to_date' GROUP BY DATE(date_time) ");

while($row= mysql_fetch_array($wip))
{
$wiprecord[]= array(
$row['date'],
$row['call_count']
);

}
$chk=0;

foreach ( $record1 as $key=> $value ) {
if($chk==1){
$get_first_array[$key] = $record1[$key];
}

foreach ( $wiprecord as $key=> $value1) {
end($wiprecord);

$last=key($wiprecord);
if($key==$last ){
$chk=1;
}
if($value[0] == $value1[0] )
{
array_push($record1[$key], $wiprecord[$key][1]);
$get_first_array[$key] = $record1[$key];
print_r( $get_first_array[$key]);
}
}
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.