Hi pals,
I got a complex Array from the Query. it's Structure is like

Array
(
[0] => Array
(
[server_name] => anes.admod.net
[id] => 1
[server_id] => 1
[description] => nice Anes Server
[status] => 0
[max_down_count] => 9
[check_interval] => 15
[fail_recheck] => 6
[log_retain] => 1
[warning] => 12
[critical] => 15
[timeout] => 8
[audible] => Y
[email] => Y
[im] => Y
[sms] => Y
[rss] => N
[rssid] =>
[vcare] => Y
[created] => 2010-12-06 10:26:26
[last_update] => 2010-12-13 16:41:48
[name] => POP3
[port] => 110
[okay] => OK
[warn] => WARNING
[crit] => CRITICAL
[down] => Connection refused
[advanced] => N
[typestatus] => 1
)

[1] => Array
(
[server_name] => neseema.admod.net
[id] => 2
[server_id] => 2
[description] => another server
[status] => 1
[max_down_count] => 11
[check_interval] => 15
[fail_recheck] => 12
[log_retain] => 2
[warning] => 12
[critical] => 16
[timeout] => 6
[audible] => Y
[email] => Y
[im] => Y
[sms] => N
[rss] => N
[rssid] =>
[vcare] => N
[created] => 2010-12-07 10:27:42
[last_update] => 2010-12-13 16:41:48
[name] => Cpanel
[port] => 2082
[okay] => OK
[warn] => WARNING
[crit] => CRITICAL
[down] => Connection refused
[advanced] => N
[typestatus] => 1
)

[2] => Array
(
[server_name] => anes.admod.net
[id] => 3
[server_id] => 1
[description] => nice Anes Server another Service
[status] => 1
[max_down_count] => 14
[check_interval] => 15
[fail_recheck] => 3
[log_retain] => 3
[warning] => 12
[critical] => 16
[timeout] => 18
[audible] => Y
[email] =>
[im] =>
[sms] =>
[rss] => N
[rssid] =>
[vcare] => N
[created] => 2010-12-07 12:58:01
[last_update] => 2010-12-13 16:41:48
[name] => SMTP
[port] => 25
[okay] => OK
[warn] => WARNING
[crit] => CRITICAL
[down] => Connection refused
[advanced] => N
[typestatus] => 1
)

)

In this Result I have 2 Rows in result to show, I mean I need to merge the data of First (0th) and Third(2nd) element because it display the
data of same item. So How it can done, I am working in that whole day but not get a solution fully.... I saw a near solution like :

<?php
 
$input = array(
 
                0 => array ( 'id' => 160, 'payment_period' => 'Monthly', 'plan_payment_type_id' => 171, 'payment_type_id' => 4), 
                1 => Array ( 'id' => 160, 'payment_period' => 'Monthly', 'plan_payment_type_id' => 172, 'payment_type_id' => 5), 
                2 => Array ( 'id' => 161, 'payment_period' => 'Weekly', 'plan_payment_type_id' => 173, 'payment_type_id' => 9), 
                );  

echo "<pre>"; 
print_r($input);
echo "</pre>";  
echo "****************************************************************************";
$output = array();
$id_array = array();
$i = 0;
foreach($input as $key=>$val) {
        if(array_key_exists($val['id'],$id_array)) {
                $pos = $id_array[$val['id']];
                $output[$pos]['payment_types'][] = array('plan_payment_type_id'=> $val['plan_payment_type_id'],'payment_type_id' => $val['payment_type_id']);
        } else {
                $output[$i] = array('id' => $val['id'],'payment_period' => $val['payment_period'],'payment_types' => array(array('plan_payment_type_id'=> $val['plan_payment_type_id'],'payment_type_id' => $val['payment_type_id'])));
                $id_array[$val['id']] = $i; 
                $i++;
        }   
}
echo "<pre>"; 
print_r($output);
echo "</pre>";  
?>

But I cannot handle it nicely, please give any sample or helping code idea for same , waiting your immediate Reply

Thankfully
Anes P.A ::)

what is your query? If data is the same, then maybe the query needs to be adjusted....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.