swapnil7779 Posted May 2, 2013 Share Posted May 2, 2013 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]); } } } Link to comment https://forums.phpfreaks.com/topic/277535-merrging-two-arrays-at-specific-date-if-both-date-matched/ Share on other sites More sharing options...
KevinM1 Posted May 2, 2013 Share Posted May 2, 2013 In the future, please post questions about your PHP code in our PHP Coding Help section, and place any code you want us to see within tags (you can either do that manually, or by clicking the <> button on the editor). Link to comment https://forums.phpfreaks.com/topic/277535-merrging-two-arrays-at-specific-date-if-both-date-matched/#findComment-1427773 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.