formatting an array using php - php

I have the following array which have duplicate data:
Array
(
[0] => Array
(
[orders] => Array
(
[id] => 9
[name] => Abdus Sattar Bhuiyan
[email] => sattar.kuet#gmail.com
[mobile] => 01673050495
[alt_mobile] => 01818953250
[city_id] => 2
[location_id] => 5
[status] => No contact
[chashed] => NO
[created] => 2015-06-27 12:49:34
[modified] => 2015-06-27 12:49:34
[comment] =>
)
[order_products] => Array
(
[id] => 2
[order_id] => 9
[product_id] => 1
[pieces] => 1
)
[products] => Array
(
[id] => 1
[category_id] => 1
[name] => নভোযানের নাম সি প্রোগ্রামিং
[writer] => Engr. Abdus Sattar Bhuiyan
[created] => 2015-06-24 16:17:45
)
[psettings] => Array
(
[id] => 1
[category_id] => 1
[product_id] => 1
[img] => 1.jpg
[desc] => description
[created] => 2015-06-28 00:28:26
[bppp] => 44000
[sppp] => 45000
[discount] => 25
[service_charge] => 30
)
)
[1] => Array
(
[orders] => Array
(
[id] => 10
[name] => Abdus Sattar Bhuiyan
[email] => sattar.kuet#gmail.com
[mobile] => 01673050495
[alt_mobile] => 01818953250
[city_id] => 1
[location_id] => 1
[status] => No contact
[chashed] => NO
[created] => 2015-06-28 03:30:25
[modified] => 2015-06-28 03:30:25
[comment] =>
)
[order_products] => Array
(
[id] => 6
[order_id] => 10
[product_id] => 1
[pieces] => 1
)
[products] => Array
(
[id] => 1
[category_id] => 1
[name] => নভোযানের নাম সি প্রোগ্রামিং
[writer] => Engr. Abdus Sattar Bhuiyan
[created] => 2015-06-24 16:17:45
)
[psettings] => Array
(
[id] => 1
[category_id] => 1
[product_id] => 1
[img] => 1.jpg
[desc] => description
[created] => 2015-06-28 00:28:26
[bppp] => 44000
[sppp] => 45000
[discount] => 25
[service_charge] => 30
)
)
[2] => Array
(
[orders] => Array
(
[id] => 9
[name] => Abdus Sattar Bhuiyan
[email] => sattar.kuet#gmail.com
[mobile] => 01673050495
[alt_mobile] => 01818953250
[city_id] => 2
[location_id] => 5
[status] => No contact
[chashed] => NO
[created] => 2015-06-27 12:49:34
[modified] => 2015-06-27 12:49:34
[comment] =>
)
[order_products] => Array
(
[id] => 3
[order_id] => 9
[product_id] => 2
[pieces] => 1
)
[products] => Array
(
[id] => 2
[category_id] => 1
[name] => Resonance of creativity with C++
[writer] => Engr. Abdus Sattar Bhuiyan
[created] => 2015-06-26 07:32:52
)
[psettings] => Array
(
[id] => 2
[category_id] => 1
[product_id] => 2
[img] => 2.jpg
[desc] =>
[created] => 2015-06-26 07:33:41
[bppp] => 150
[sppp] => 250
[discount] => 20
[service_charge] => 30
)
)
[3] => Array
(
[orders] => Array
(
[id] => 10
[name] => Abdus Sattar Bhuiyan
[email] => sattar.kuet#gmail.com
[mobile] => 01673050495
[alt_mobile] => 01818953250
[city_id] => 1
[location_id] => 1
[status] => No contact
[chashed] => NO
[created] => 2015-06-28 03:30:25
[modified] => 2015-06-28 03:30:25
[comment] =>
)
[order_products] => Array
(
[id] => 5
[order_id] => 10
[product_id] => 2
[pieces] => 1
)
[products] => Array
(
[id] => 2
[category_id] => 1
[name] => Resonance of creativity with C++
[writer] => Engr. Abdus Sattar Bhuiyan
[created] => 2015-06-26 07:32:52
)
[psettings] => Array
(
[id] => 2
[category_id] => 1
[product_id] => 2
[img] => 2.jpg
[desc] =>
[created] => 2015-06-26 07:33:41
[bppp] => 150
[sppp] => 250
[discount] => 20
[service_charge] => 30
)
)
[4] => Array
(
[orders] => Array
(
[id] => 9
[name] => Abdus Sattar Bhuiyan
[email] => sattar.kuet#gmail.com
[mobile] => 01673050495
[alt_mobile] => 01818953250
[city_id] => 2
[location_id] => 5
[status] => No contact
[chashed] => NO
[created] => 2015-06-27 12:49:34
[modified] => 2015-06-27 12:49:34
[comment] =>
)
[order_products] => Array
(
[id] => 4
[order_id] => 9
[product_id] => 3
[pieces] => 1
)
[products] => Array
(
[id] => 3
[category_id] => 1
[name] => programming by story C
[writer] => Hasibul Hasan Shanto
[created] => 2015-06-26 07:35:57
)
[psettings] => Array
(
[id] => 3
[category_id] => 1
[product_id] => 3
[img] => 3.jpg
[desc] =>
[created] => 2015-06-26 07:36:26
[bppp] => 150
[sppp] => 250
[discount] => 10
[service_charge] => 30
)
)
[5] => Array
(
[orders] => Array
(
[id] => 10
[name] => Abdus Sattar Bhuiyan
[email] => sattar.kuet#gmail.com
[mobile] => 01673050495
[alt_mobile] => 01818953250
[city_id] => 1
[location_id] => 1
[status] => No contact
[chashed] => NO
[created] => 2015-06-28 03:30:25
[modified] => 2015-06-28 03:30:25
[comment] =>
)
[order_products] => Array
(
[id] => 7
[order_id] => 10
[product_id] => 3
[pieces] => 1
)
[products] => Array
(
[id] => 3
[category_id] => 1
[name] => programming by story C
[writer] => Hasibul Hasan Shanto
[created] => 2015-06-26 07:35:57
)
[psettings] => Array
(
[id] => 3
[category_id] => 1
[product_id] => 3
[img] => 3.jpg
[desc] =>
[created] => 2015-06-26 07:36:26
[bppp] => 150
[sppp] => 250
[discount] => 10
[service_charge] => 30
)
)
)
I want to format this array and produce the following array:
Array
(
[0] => Array
(
[orders] => Array
(
[id] => 9
[name] => Abdus Sattar Bhuiyan
[email] => sattar.kuet#gmail.com
[mobile] => 01673050495
[alt_mobile] => 01818953250
[city_id] => 2
[location_id] => 5
[status] => No contact
[chashed] => NO
[created] => 2015-06-27 12:49:34
[modified] => 2015-06-27 12:49:34
[comment] =>
)
[order_products] => Array
(
[0] => Array
(
[id] => 2
[order_id] => 9
[product_id] => 1
[pieces] => 1
)
[1] => Array
(
[id] => 3
[order_id] => 9
[product_id] => 2
[pieces] => 1
)
[2] => Array
(
[id] => 4
[order_id] => 9
[product_id] => 3
[pieces] => 1
)
)
[products] => Array
(
[0] => Array
(
[id] => 1
[category_id] => 1
[name] => নভোযানের নাম সি প্রোগ্রামিং
[writer] => Engr. Abdus Sattar Bhuiyan
[created] => 2015-06-24 16:17:45
)
[1] => Array
(
[id] => 2
[category_id] => 1
[name] => Resonance of creativity with C++
[writer] => Engr. Abdus Sattar Bhuiyan
[created] => 2015-06-26 07:32:52
)
[2] => Array
(
[id] => 3
[category_id] => 1
[name] => programming by story C
[writer] => Hasibul Hasan Shanto
[created] => 2015-06-26 07:35:57
)
)
[psettings] => Array
(
[0] => Array
(
[id] => 1
[category_id] => 1
[product_id] => 1
[img] => 1.jpg
[desc] => description
[created] => 2015-06-28 00:28:26
[bppp] => 44000
[sppp] => 45000
[discount] => 25
[service_charge] => 30
)
[1] => Array
(
[id] => 2
[category_id] => 1
[product_id] => 2
[img] => 2.jpg
[desc] =>
[created] => 2015-06-26 07:33:41
[bppp] => 150
[sppp] => 250
[discount] => 20
[service_charge] => 30
)
[2] => Array
(
[id] => 3
[category_id] => 1
[product_id] => 3
[img] => 3.jpg
[desc] =>
[created] => 2015-06-26 07:36:26
[bppp] => 150
[sppp] => 250
[discount] => 10
[service_charge] => 30
)
)
)
[1] => Array
(
[orders] => Array
(
[id] => 10
[name] => Abdus Sattar Bhuiyan
[email] => sattar.kuet#gmail.com
[mobile] => 01673050495
[alt_mobile] => 01818953250
[city_id] => 1
[location_id] => 1
[status] => No contact
[chashed] => NO
[created] => 2015-06-28 03:30:25
[modified] => 2015-06-28 03:30:25
[comment] =>
)
[order_products] => Array
(
[0] => Array
( [id] => 6
[order_id] => 10
[product_id] => 1
[pieces] => 1
)
[1] => Array
(
[id] => 5
[order_id] => 10
[product_id] => 2
[pieces] => 1
)
[2] => Array
(
[id] => 7
[order_id] => 10
[product_id] => 3
[pieces] => 1
)
)
[products] => Array
(
[0] => Array
(
[id] => 1
[category_id] => 1
[name] => নভোযানের নাম সি প্রোগ্রামিং
[writer] => Engr. Abdus Sattar Bhuiyan
[created] => 2015-06-24 16:17:45
)
[1] => Array
(
[id] => 2
[category_id] => 1
[name] => Resonance of creativity with C++
[writer] => Engr. Abdus Sattar Bhuiyan
[created] => 2015-06-26 07:32:52
)
[2] => Array
(
[id] => 3
[category_id] => 1
[name] => programming by story C
[writer] => Hasibul Hasan Shanto
[created] => 2015-06-26 07:35:57
)
)
[psettings] => Array
(
[0] => Array
(
[id] => 1
[category_id] => 1
[product_id] => 1
[img] => 1.jpg
[desc] => description
[created] => 2015-06-28 00:28:26
[bppp] => 44000
[sppp] => 45000
[discount] => 25
[service_charge] => 30
)
[1] => Array
(
[id] => 2
[category_id] => 1
[product_id] => 2
[img] => 2.jpg
[desc] =>
[created] => 2015-06-26 07:33:41
[bppp] => 150
[sppp] => 250
[discount] => 20
[service_charge] => 30
)
[2] => Array
(
[id] => 3
[category_id] => 1
[product_id] => 3
[img] => 3.jpg
[desc] =>
[created] => 2015-06-26 07:36:26
[bppp] => 150
[sppp] => 250
[discount] => 10
[service_charge] => 30
)
)
)
)
How can I do this. I reformat simple array but this does not make sense to me to format. It makes me cry. Please help me. If any helper function is suggested it will be really a gift. Thanks in advance.

You need to do like below:-
<?php
$firstArray = Array
(
'0' => Array
(
'orders' => Array
(
'id' => 9,
'name' => 'Abdus Sattar Bhuiyan',
'email' => 'sattar.kuet#gmail.com',
'mobile' => '01673050495',
'alt_mobile' => '01818953250',
'city_id' => 2,
'location_id' => 5,
'status' => 'No contact',
'chashed' => 'NO',
'created' => '2015-06-27 12:49:34',
'modified' => '2015-06-27 12:49:34',
'comment' => ''
),
'order_products' => Array
(
'id' => 2,
'order_id' => 9,
'product_id' => 1,
'pieces' => 1
),
'products' => Array
(
'id' => 1,
'category_id' => 1,
'name' => 'নভোযানের নাম সি প্রোগ্রামিং',
'writer' => 'Engr. Abdus Sattar Bhuiyan',
'created' => '2015-06-24 16:17:45'
),
'psettings' => Array
(
'id' => 1,
'category_id' => 1,
'product_id' => 1,
'img' => '1.jpg',
'desc' => 'description',
'created' => '2015-06-28 00:28:26',
'bppp' => 44000,
'sppp' => 45000,
'discount' => 25,
'service_charge' => 30
),
),
'1' => Array
(
'orders' => Array
(
'id' => 9,
'name' => 'Abdus Sattar Bhuiyan',
'email' => 'sattar.kuet#gmail.com',
'mobile' => '01673050495',
'alt_mobile' => '01818953250',
'city_id' => 2,
'location_id' => 5,
'status' => 'No contact',
'chashed' => 'NO',
'created' => '2015-06-27 12:49:34',
'modified' => '2015-06-27 12:49:34',
'comment' => ''
),
'order_products' => Array
(
'id' => 3,
'order_id' => 9,
'product_id' => 2,
'pieces' => 1
),
'products' => Array
(
'id' => 2,
'category_id' => 1,
'name' => 'Resonance of creativity with C++',
'writer' => 'Engr. Abdus Sattar Bhuiyan',
'created' => '2015-06-26 07:32:52'
),
'psettings' => Array
(
'id' => 2,
'category_id' => 1,
'product_id' => 2,
'img' => '2.jpg',
'desc' => '',
'created' => '2015-06-26 07:33:41',
'bppp' => 150,
'sppp' => 250,
'discount' => 20,
'service_charge' => 30
),
),
'2' => Array
(
'orders' => Array
(
'id' => 9,
'name' => 'Abdus Sattar Bhuiyan',
'email' => 'sattar.kuet#gmail.com',
'mobile' => '01673050495',
'alt_mobile' => '01818953250',
'city_id' => 2,
'location_id' => 5,
'status' => 'No contact',
'chashed' => 'NO',
'created' => '2015-06-27 12:49:34',
'modified' => '2015-06-27 12:49:34',
'comment' => ''
),
'order_products' => Array
(
'id' => 4,
'order_id' => 9,
'product_id' => 3,
'pieces' => 1
),
'products' => Array
(
'id' => 3,
'category_id' => 1,
'name' => 'programming by story C',
'writer' => 'Hasibul Hasan Shanto',
'created' => '2015-06-26 07:35:57'
),
'psettings' => Array
(
'id' => 3,
'category_id' => 1,
'product_id' => 3,
'img' => '3.jpg',
'desc' => '',
'created' => '2015-06-26 07:36:26',
'bppp' => 150,
'sppp' => 250,
'discount' => 10,
'service_charge' => 30
),
),
);
$new_array = array();
foreach($firstArray as $key=> $arr){
if($key == 0){
$new_array[0]['orders'] = $arr['orders'];
$new_array[0]['order_products'][] = $arr['order_products'];
$new_array[0]['products'][] = $arr['products'];
$new_array[0]['psettings'][] = $arr['psettings'];
}else{
foreach($new_array as $key=> $newarr){
if($arr['orders'] == $newarr['orders']){
$new_array[$key]['order_products'][] = $arr['order_products'];
$new_array[$key]['products'][] = $arr['products'];
$new_array[$key]['psettings'][] = $arr['psettings'];
}else{
$new_array[] = $arr;
}
}
}
}
echo "<pre/>";print_r($new_array);
?>
Output:- https://eval.in/388565.
Note:- don't worry about the array i putted. I just take your array and formatted it for running purpose and checking at my end. thanks.

This is a fairly simple job for array_column() (manual reference). Like this ($array is your source):
$composite = [];
$composite['orders'] = array_column($array, 'orders')[0];
$composite['order_products'] = array_column($array, 'order_products');
$composite['products'] = array_column($array, 'products');
$composite['psettings'] = array_column($array, 'psettings');
print_r($composite);
This results in the following array:
Array
(
[orders] => Array
(
[id] => 9
[name] => Abdus Sattar Bhuiyan
[email] => sattar.kuet#gmail.com
[mobile] => 01673050495
[alt_mobile] => 01818953250
[city_id] => 2
[location_id] => 5
[status] => No contact
[chashed] => NO
[created] => 2015-06-27 12:49:34
[modified] => 2015-06-27 12:49:34
[comment] =>
)
[order_products] => Array
(
[0] => Array
(
[id] => 2
[order_id] => 9
[product_id] => 1
[pieces] => 1
)
[1] => Array
(
[id] => 3
[order_id] => 9
[product_id] => 2
[pieces] => 1
)
[2] => Array
(
[id] => 4
[order_id] => 9
[product_id] => 3
[pieces] => 1
)
)
[products] => Array
(
[0] => Array
(
[id] => 1
[category_id] => 1
[name] => নভোযানের নাম সি প্রোগ্রামিং
[writer] => Engr. Abdus Sattar Bhuiyan
[created] => 2015-06-24 16:17:45
)
[1] => Array
(
[id] => 2
[category_id] => 1
[name] => Resonance of creativity with C++
[writer] => Engr. Abdus Sattar Bhuiyan
[created] => 2015-06-26 07:32:52
)
[2] => Array
(
[id] => 3
[category_id] => 1
[name] => programming by story C
[writer] => Hasibul Hasan Shanto
[created] => 2015-06-26 07:35:57
)
)
[psettings] => Array
(
[0] => Array
(
[id] => 1
[category_id] => 1
[product_id] => 1
[img] => 1.jpg
[desc] => description
[created] => 2015-06-28 00:28:26
[bppp] => 44000
[sppp] => 45000
[discount] => 25
[service_charge] => 30
)
[1] => Array
(
[id] => 2
[category_id] => 1
[product_id] => 2
[img] => 2.jpg
[desc] =>
[created] => 2015-06-26 07:33:41
[bppp] => 150
[sppp] => 250
[discount] => 20
[service_charge] => 30
)
[2] => Array
(
[id] => 3
[category_id] => 1
[product_id] => 3
[img] => 3.jpg
[desc] =>
[created] => 2015-06-26 07:36:26
[bppp] => 150
[sppp] => 250
[discount] => 10
[service_charge] => 30
)
)
)
If you need to aggregate multiple such arrays into one master array that contains it all, then you can for example wrap it inside a simple loop and add a numeric index for each composite set:
$composite = [];
foreach($arrays as $num=>$array) {
$composite[$num]['orders'] = array_column... // etc.
}
Also make note of the index_key feature of array_column mentioned in the manual, may come in handy if you want to use the order IDs as the main keys --- though for that, you'd have to re-factor the loop logic a bit. Let me know if it's a relevant concern and I'll add more; or if this is enough as-is.

Related

PHP5.3 json_encode is outputting bad json

I am attempting to json_encode an array in php5.3.
json_encode($paperwork_info[0])
The result is bad json. The array is as follows:
[paperwork_guid] => c5bfe512-908d-c513-5a5e-e3a2fbb5548b
[name] => recycle
[sections] => Array
(
[0] => header
[1] => customer
[2] => scope_bullets
[3] => product
[4] => signature
[5] => installer
[6] => order_data
)
[data] => Array
(
[header] => Array
(
[image] => Array
(
[src] => recycle.png
[format] => float:left
)
)
[customer] => Array
(
[f_name] => TEST ONLY
[l_name] => NEIMEIER
[middle_name] => none
[title] => none
[address1] => 28 OEHMAN BLVD
[address2] =>
[address3] =>
[zip] => 14225
[city] => BUFFALO
[state_abbrev] => NY
[email_address] => DALE.NEIMEIER#INSTALLS.COM
[phones] => Array
(
[alt] =>
[cell] =>
[work] =>
[home] => 7165551212
)
)
[scope_bullets] => Array
(
[sku_3001] => Array
(
[bullet_0] => Array
(
[paperwork_bullet_obj_guid] => 2ebefa96-6f6b-069e-e194-245d138b9845
[ordering] => 1
[bullet_text] => This is bullet point #1
[child_level] => 1
[formatting] => Array
(
[0] => Array
(
[start_word] => 2
[num_words] => 0
[tag] => b
[href] =>
)
[1] => Array
(
[start_word] => 2
[num_words] => 1
[tag] => a
[href] => http://www.cnn.com
)
)
)
[bullet_1] => Array
(
[paperwork_bullet_obj_guid] => 734db3f4-01a0-b025-9624-cc52a1845dff
[ordering] => 1
[bullet_text] => Sub-point #1.1
[child_level] => 2
)
[bullet_2] => Array
(
[paperwork_bullet_obj_guid] => ebf5ef02-906e-2005-e499-27eae2edefe9
[ordering] => 1
[bullet_text] => Sub point #1.1.1
[child_level] => 3
)
[bullet_3] => Array
(
[paperwork_bullet_obj_guid] => 447997c1-fd9c-25be-b9bf-39257009fb8b
[ordering] => 1
[bullet_text] => This is bullet point #2
[child_level] => 1
)
[bullet_4] => Array
(
[paperwork_bullet_obj_guid] => 5def2d9c-d322-788c-0afe-d13707004b97
[ordering] => 1
[bullet_text] => Sub point #2.1
[child_level] => 2
)
[bullet_5] => Array
(
[paperwork_bullet_obj_guid] => 84936151-65a3-bcca-951f-b69ff16d34ec
[ordering] => 2
[bullet_text] => Sub point #2.2
[child_level] => 2
)
)
[sku_4405] =>
)
[product] => Array
(
[0] => Array
(
[model] => Paperwork Test abc123
[serial] => 777333
[weight] => 26
[size] =>
[width] =>
[height] => 32
[num_boxes] => 1
[product_name] =>
[sku] =>
[model_number] =>
[part_number] =>
[serial_number] =>
[cat_value] => Best Buy Equipment
[product] =>
[product_type] =>
[product_size] =>
[category] =>
)
)
[signature] => Array
(
[date] => 2016-06-15
[need_customer] => 1
[need_tech] => 1
[need_store] =>
[need_warehouse] =>
)
[installer] => Array
(
[anum] => 45455
[inst_obj_guid] => fb91cf85-381c-b740-e063-775151743da2
[phone] => (317) 519-0481
[tech_f_name] =>
[tech_l_name] =>
[company_name] => ZICO LLC
[email_address] => ZICOLLC#GMAIL.COM
)
[order_data] => Array
(
[assigned_date] => 2016-06-07 22:24:47-04
[purchased_date] => 2016-06-06
[creation_date] => 2016-06-06
[install_date] => 2016-06-10
[install_time] => 19:00:00
[prescheduled_date] => 1969-12-31
[prom_start_time] => 2016-06-10 08:06:00
[prom_end_time] => 2016-06-10 11:06:00
[client_order_id] => 12365478996325412
[job_num] => 4043269
[campaign_wkord_obj_guid] => a9a8cc0b-d7ef-ac0e-df61-dad41c023cb0
[pos_obj_guid] => 096e38c2-55c3-80cf-0778-23f81f1cf2f6
[inst_obj_guid] => fb91cf85-381c-b740-e063-775151743da2
[client_obj_guid] => 247e893a-3ea4-c544-47b2-f23ff16017c6
[ord_obj_guid] => ae55e034-d7d0-5d13-3dd3-22f99df8ead4
[skus] => Array
(
[0] => Array
(
[job_type_obj_guid] => 8234ca2c-e40e-c48c-befc-7ceac5e9de32
[job_sku] => 3001
[client_sku] =>
[sku_name] => Site Survey
)
[1] => Array
(
[job_type_obj_guid] => a3f60c3b-ad3c-d828-9898-fa200edcd3cd
[job_sku] => 4405
[client_sku] =>
[sku_name] => Home Delivery
)
)
[client_specific_data] =>
)
)
)
The resultant json string is as follows:
{"paperwork_guid":"c5bfe512-908d-c513-5a5e-e3a2fbb5548b","name":"recycle","sections":{"0":"header","1"
:"customer","2":"scope_bullets","3":"product","4":"signature","5":"installer","6":"order_data"},"data"
:{"header":{"image":{"src":"recycle.png","format":"float:left"}},"customer":{"f_name":"TEST ONLY","l_name"
:"NEIMEIER","middle_name":"none","title":"none","address1":"28 OEHMAN BLVD","address2":"","address3"
:null,"zip":"14225","city":"BUFFALO","state_abbrev":"NY","email_address":"DALE.NEIMEIER#INSTALLS.COM"
,"phones":{"alt":"","cell":"","work":"","home":"7165551212"}},"scope_bullets":{"sku_3001":{"bullet_0"
:{"paperwork_bullet_obj_guid":"2ebefa96-6f6b-069e-e194-245d138b9845","ordering":"1","bullet_text":"This
is bullet point #1","child_level":"1","formatting":{"0":{"start_word":"2","num_words":"0","tag":"b"
,"href":""},"1":{"start_word":"2","num_words":"1","tag":"a","href":"http:\/\/www.cnn.com"}}},"bullet_1"
:{"paperwork_bullet_obj_guid":"734db3f4-01a0-b025-9624-cc52a1845dff","ordering":"1","bullet_text":"Sub-point
#1.1","child_level":"2"},"bullet_2":{"paperwork_bullet_obj_guid":"ebf5ef02-906e-2005-e499-27eae2edefe9"
,"ordering":"1","bullet_text":"Sub point #1.1.1","child_level":"3"},"bullet_3":{"paperwork_bullet_obj_guid"
:"447997c1-fd9c-25be-b9bf-39257009fb8b","ordering":"1","bullet_text":"This is bullet point #2","child_level"
:"1"},"bullet_4":{"paperwork_bullet_obj_guid":"5def2d9c-d322-788c-0afe-d13707004b97","ordering":"1","bullet_text"
:"Sub point #2.1","child_level":"2"},"bullet_5":{"paperwork_bullet_obj_guid":"84936151-65a3-bcca-951f-b69ff16d34ec"
,"ordering":"2","bullet_text":"Sub point #2.2","child_level":"2"}},"sku_4405":null},"product":{"0":{"model"
:"Paperwork Test abc123","serial":"777333","weight":"26","size":null,"width":null,"height":"32","num_boxes"
:"1","product_name":null,"sku":null,"model_number":null,"part_number":null,"serial_number":null,"cat_value"
:"Best Buy Equipment","product":null,"product_type":null,"product_size":null,"category":null}},"signature"
:{"date":"2016-06-15","need_customer":true,"need_tech":true,"need_store":false,"need_warehouse":false
},"installer":{"anum":"45455","inst_obj_guid":"fb91cf85-381c-b740-e063-775151743da2","phone":"(317) 519-0481"
,"tech_f_name":null,"tech_l_name":null,"company_name":"ZICO LLC","email_address":"ZICOLLC#GMAIL.COM"
},"order_data":{"assigned_date":"2016-06-07 22:24:47-04","purchased_date":"2016-06-06","creation_date"
:"2016-06-06","install_date":"2016-06-10","install_time":"19:00:00","prescheduled_date":"1969-12-31"
,"prom_start_time":"2016-06-10 08:06:00","prom_end_time":"2016-06-10 11:06:00","client_order_id":"12365478996325412"
,"job_num":"4043269","campaign_wkord_obj_guid":"a9a8cc0b-d7ef-ac0e-df61-dad41c023cb0","pos_obj_guid"
:"096e38c2-55c3-80cf-0778-23f81f1cf2f6","inst_obj_guid":"fb91cf85-381c-b740-e063-775151743da2","client_obj_guid"
:"247e893a-3ea4-c544-47b2-f23ff16017c6","ord_obj_guid":"ae55e034-d7d0-5d13-3dd3-22f99df8ead4","skus"
:{"0":{"job_type_obj_guid":"8234ca2c-e40e-c48c-befc-7ceac5e9de32","job_sku":"3001","client_sku":null
,"sku_name":"Site Survey"},"1":{"job_type_obj_guid":"a3f60c3b-ad3c-d828-9898-fa200edcd3cd","job_sku"
:"4405","client_sku":null,"sku_name":"Home Delivery"}},"client_specific_data":""}}}
It appears as though new line feeds are being inserted randomly throughout the josn string. I am not sure if it is just how firebug is outputting the string, but copying-and-pasting the string into jsonLINT produces errors.
Any help would be appreciated.

Left join return duplicate data although I used GROUP BY

SQL:
$sql = "SELECT orders.*,order_products.*,products.*,psettings.*,cities.*,locations.* FROM orders
LEFT JOIN order_products ON orders.id=order_products.order_id
LEFT JOIN products ON products.id=order_products.product_id
LEFT JOIN psettings ON psettings.product_id=order_products.product_id
LEFT JOIN cities ON cities.id=orders.city_id
LEFT JOIN locations ON locations.id=orders.location_id
WHERE orders.status = '$status'
ORDER BY orders.id ASC ";
It returns unique data. Here is the returned data:
Array
(
[orders] => Array
(
[id] => 12
[name] => Abdus Sattar Bhuiyan
[email] => sattar.kuet#gmail.com
[mobile] => 01673050495
[alt_mobile] => 01818953250
[city_id] => 2
[location_id] => 5
[status] => confirmed
[cashed] => 1115
[created] => 2015-07-02 01:07:18
[modified] => 2015-07-02 01:01:57
[comment] => 07/02/2015 06:00 am
)
[city] => Array
(
[id] => 2
[name] => comilla
)
[location] => Array
(
[id] => 5
[city_id] => 2
[name] => homna
)
[order_products] => Array
(
[0] => Array
(
[id] => 10
[order_id] => 12
[product_id] => 1
[pieces] => 1
)
[1] => Array
(
[id] => 11
[order_id] => 12
[product_id] => 2
[pieces] => 1
)
[2] => Array
(
[id] => 12
[order_id] => 12
[product_id] => 3
[pieces] => 3
)
)
[products] => Array
(
[0] => Array
(
[id] => 1
[category_id] => 1
[name] => নভোযানের নাম সি প্রোগ্রামিং
[writer] => Engr. Abdus Sattar Bhuiyan
[created] => 2015-06-24 16:17:45
)
[1] => Array
(
[id] => 2
[category_id] => 1
[name] => Resonance of creativity with C++
[writer] => Engr. Abdus Sattar Bhuiyan
[created] => 2015-06-26 07:32:52
)
[2] => Array
(
[id] => 3
[category_id] => 1
[name] => programming by story C
[writer] => Hasibul Hasan Shanto
[created] => 2015-06-26 07:35:57
)
)
[psettings] => Array
(
[0] => Array
(
[id] => 1
[category_id] => 1
[product_id] => 1
[img] => 1.jpg
[desc] => description
[created] => 2015-06-29 15:15:58
[bppp] => 165
[sppp] => 300
[discount] => 20
[service_charge] => 30
)
[1] => Array
(
[id] => 2
[category_id] => 1
[product_id] => 2
[img] => 2.jpg
[desc] =>
[created] => 2015-06-26 07:33:41
[bppp] => 150
[sppp] => 250
[discount] => 20
[service_charge] => 30
)
[2] => Array
(
[id] => 3
[category_id] => 1
[product_id] => 3
[img] => 3.jpg
[desc] =>
[created] => 2015-06-26 07:36:26
[bppp] => 150
[sppp] => 250
[discount] => 10
[service_charge] => 30
)
)
)
But When I Add another table to join left with orders table it returns duplicate entry. Additionally I join left 'action_bies' with orders table as follows:
$sql = "SELECT orders.*,order_products.*,products.*,psettings.*,cities.*,locations.*,action_bies.* FROM orders
LEFT JOIN order_products ON orders.id=order_products.order_id
LEFT JOIN action_bies ON orders.id=action_bies.order_id AND action_bies.action='$action'
LEFT JOIN products ON products.id=order_products.product_id
LEFT JOIN psettings ON psettings.product_id=order_products.product_id
LEFT JOIN cities ON cities.id=orders.city_id
LEFT JOIN locations ON locations.id=orders.location_id
WHERE orders.status = '$status'
ORDER BY orders.id ASC ";
This sql return duplicate data. Here is the data:
Array
(
[orders] => Array
(
[id] => 12
[name] => Abdus Sattar Bhuiyan
[email] => sattar.kuet#gmail.com
[mobile] => 01673050495
[alt_mobile] => 01818953250
[city_id] => 2
[location_id] => 5
[status] => confirmed
[cashed] => 1115
[created] => 2015-07-02 01:07:18
[modified] => 2015-07-02 01:01:57
[comment] => 07/02/2015 06:00 am
)
[city] => Array
(
[id] => 2
[name] => comilla
)
[location] => Array
(
[id] => 5
[city_id] => 2
[name] => homna
)
[action] => Array
(
[0] => Array
(
[id] => 1
[action] => confirm
[admin_id] => 30
[order_id] => 12
[created] => 0000-00-00 00:00:00
)
[1] => Array
(
[id] => 4
[action] => confirm
[admin_id] => 30
[order_id] => 12
[created] => 2015-07-02 00:00:00
)
[2] => Array
(
[id] => 5
[action] => confirm
[admin_id] => 30
[order_id] => 12
[created] => 2015-07-02 00:00:00
)
[3] => Array
(
[id] => 1
[action] => confirm
[admin_id] => 30
[order_id] => 12
[created] => 0000-00-00 00:00:00
)
[4] => Array
(
[id] => 4
[action] => confirm
[admin_id] => 30
[order_id] => 12
[created] => 2015-07-02 00:00:00
)
[5] => Array
(
[id] => 5
[action] => confirm
[admin_id] => 30
[order_id] => 12
[created] => 2015-07-02 00:00:00
)
[6] => Array
(
[id] => 1
[action] => confirm
[admin_id] => 30
[order_id] => 12
[created] => 0000-00-00 00:00:00
)
[7] => Array
(
[id] => 4
[action] => confirm
[admin_id] => 30
[order_id] => 12
[created] => 2015-07-02 00:00:00
)
[8] => Array
(
[id] => 5
[action] => confirm
[admin_id] => 30
[order_id] => 12
[created] => 2015-07-02 00:00:00
)
)
[order_products] => Array
(
[0] => Array
(
[id] => 10
[order_id] => 12
[product_id] => 1
[pieces] => 1
)
[1] => Array
(
[id] => 10
[order_id] => 12
[product_id] => 1
[pieces] => 1
)
[2] => Array
(
[id] => 10
[order_id] => 12
[product_id] => 1
[pieces] => 1
)
[3] => Array
(
[id] => 11
[order_id] => 12
[product_id] => 2
[pieces] => 1
)
[4] => Array
(
[id] => 11
[order_id] => 12
[product_id] => 2
[pieces] => 1
)
[5] => Array
(
[id] => 11
[order_id] => 12
[product_id] => 2
[pieces] => 1
)
[6] => Array
(
[id] => 12
[order_id] => 12
[product_id] => 3
[pieces] => 3
)
[7] => Array
(
[id] => 12
[order_id] => 12
[product_id] => 3
[pieces] => 3
)
[8] => Array
(
[id] => 12
[order_id] => 12
[product_id] => 3
[pieces] => 3
)
)
[products] => Array
(
[0] => Array
(
[id] => 1
[category_id] => 1
[name] => নভোযানের নাম সি প্রোগ্রামিং
[writer] => Engr. Abdus Sattar Bhuiyan
[created] => 2015-06-24 16:17:45
)
[1] => Array
(
[id] => 1
[category_id] => 1
[name] => নভোযানের নাম সি প্রোগ্রামিং
[writer] => Engr. Abdus Sattar Bhuiyan
[created] => 2015-06-24 16:17:45
)
[2] => Array
(
[id] => 1
[category_id] => 1
[name] => নভোযানের নাম সি প্রোগ্রামিং
[writer] => Engr. Abdus Sattar Bhuiyan
[created] => 2015-06-24 16:17:45
)
[3] => Array
(
[id] => 2
[category_id] => 1
[name] => Resonance of creativity with C++
[writer] => Engr. Abdus Sattar Bhuiyan
[created] => 2015-06-26 07:32:52
)
[4] => Array
(
[id] => 2
[category_id] => 1
[name] => Resonance of creativity with C++
[writer] => Engr. Abdus Sattar Bhuiyan
[created] => 2015-06-26 07:32:52
)
[5] => Array
(
[id] => 2
[category_id] => 1
[name] => Resonance of creativity with C++
[writer] => Engr. Abdus Sattar Bhuiyan
[created] => 2015-06-26 07:32:52
)
[6] => Array
(
[id] => 3
[category_id] => 1
[name] => programming by story C
[writer] => Hasibul Hasan Shanto
[created] => 2015-06-26 07:35:57
)
[7] => Array
(
[id] => 3
[category_id] => 1
[name] => programming by story C
[writer] => Hasibul Hasan Shanto
[created] => 2015-06-26 07:35:57
)
[8] => Array
(
[id] => 3
[category_id] => 1
[name] => programming by story C
[writer] => Hasibul Hasan Shanto
[created] => 2015-06-26 07:35:57
)
)
[psettings] => Array
(
[0] => Array
(
[id] => 1
[category_id] => 1
[product_id] => 1
[img] => 1.jpg
[desc] => description
[created] => 2015-06-29 15:15:58
[bppp] => 165
[sppp] => 300
[discount] => 20
[service_charge] => 30
)
[1] => Array
(
[id] => 1
[category_id] => 1
[product_id] => 1
[img] => 1.jpg
[desc] => description
[created] => 2015-06-29 15:15:58
[bppp] => 165
[sppp] => 300
[discount] => 20
[service_charge] => 30
)
[2] => Array
(
[id] => 1
[category_id] => 1
[product_id] => 1
[img] => 1.jpg
[desc] => description
[created] => 2015-06-29 15:15:58
[bppp] => 165
[sppp] => 300
[discount] => 20
[service_charge] => 30
)
[3] => Array
(
[id] => 2
[category_id] => 1
[product_id] => 2
[img] => 2.jpg
[desc] =>
[created] => 2015-06-26 07:33:41
[bppp] => 150
[sppp] => 250
[discount] => 20
[service_charge] => 30
)
[4] => Array
(
[id] => 2
[category_id] => 1
[product_id] => 2
[img] => 2.jpg
[desc] =>
[created] => 2015-06-26 07:33:41
[bppp] => 150
[sppp] => 250
[discount] => 20
[service_charge] => 30
)
[5] => Array
(
[id] => 2
[category_id] => 1
[product_id] => 2
[img] => 2.jpg
[desc] =>
[created] => 2015-06-26 07:33:41
[bppp] => 150
[sppp] => 250
[discount] => 20
[service_charge] => 30
)
[6] => Array
(
[id] => 3
[category_id] => 1
[product_id] => 3
[img] => 3.jpg
[desc] =>
[created] => 2015-06-26 07:36:26
[bppp] => 150
[sppp] => 250
[discount] => 10
[service_charge] => 30
)
[7] => Array
(
[id] => 3
[category_id] => 1
[product_id] => 3
[img] => 3.jpg
[desc] =>
[created] => 2015-06-26 07:36:26
[bppp] => 150
[sppp] => 250
[discount] => 10
[service_charge] => 30
)
[8] => Array
(
[id] => 3
[category_id] => 1
[product_id] => 3
[img] => 3.jpg
[desc] =>
[created] => 2015-06-26 07:36:26
[bppp] => 150
[sppp] => 250
[discount] => 10
[service_charge] => 30
)
)
)
Here it should be mentioned that a action_bies table has duplicate data as follows:
How can I get unique data in this case. Thanks to read this large data.
You can select DISTINCT on the most unique identifier you have, which would be orders_products.id most likely.
Example:
SELECT DISTINCT(orders_products.id) FROM orders_products WHERE x = '$y';
I don't see a GROUP BY statement in your original query.

How to re-arrange Array in php

Array
(
[0] => Array
(
[Product] => Array
(
[id] => 5
[user_id] => 5
[category_id] => 1
[name] => Suger
[weight] => 1
[measurement] => kg
[image] =>
[status] => 1
[created] => 2015-05-29 17:02:25
[updated] => 0000-00-00 00:00:00
)
[Category] => Array
(
[id] => 1
[user_id] => 1
[category_name] => Daily uses
[category_image] =>
[status] => 1
[created] => 2015-05-25 12:56:10
[updated] => 2015-06-25 10:27:40
)
[Storeproduct] => Array
(
[0] => Array
(
[id] => 23
[product_id] => 5
[store_id] => 2
[details] =>
[mrp] => 10
[selling_price] => 10
[discount] => 0
[price_difference] => 0
[is_deal] => 0
[deal_start_date] =>
[deal_end_date] =>
[status] => 1
[created] => 1435055384
[updated] => 1435055384
)
[1] => Array
(
[id] => 28
[product_id] => 5
[store_id] => 1
[details] =>
[mrp] => 10
[selling_price] => 10
[discount] => 0
[price_difference] => 0
[is_deal] => 0
[deal_start_date] =>
[deal_end_date] =>
[status] => 1
[created] => 1435062129
[updated] => 1435062129
)
)
)
[1] => Array
(
[Product] => Array
(
[id] => 6
[user_id] => 1
[category_id] => 1
[name] => Tea
[weight] => 1
[measurement] => litre
[image] =>
[status] => 1
[created] => 2015-05-29 17:02:48
[updated] => 2015-06-18 18:53:30
)
[Category] => Array
(
[id] => 1
[user_id] => 1
[category_name] => Daily uses
[category_image] =>
[status] => 1
[created] => 2015-05-25 12:56:10
[updated] => 2015-06-25 10:27:40
)
[Storeproduct] => Array
(
[0] => Array
(
[id] => 22
[product_id] => 6
[store_id] => 2
[details] =>
[mrp] => 10
[selling_price] => 10
[discount] => 0
[price_difference] => 0
[is_deal] => 0
[deal_start_date] =>
[deal_end_date] =>
[status] => 1
[created] => 1435055076
[updated] => 1435055076
)
[1] => Array
(
[id] => 25
[product_id] => 6
[store_id] => 1
[details] =>
[mrp] => 12
[selling_price] => 12
[discount] => 0
[price_difference] => 0
[is_deal] => 0
[deal_start_date] =>
[deal_end_date] =>
[status] => 1
[created] => 1435059905
[updated] => 1435059905
)
)
)
[5] => Array
(
[Product] => Array
(
[id] => 11
[user_id] => 2
[category_id] => 13
[name] => Real Mix Fruit Juice
[weight] => 200
[measurement] => litre
[image] =>
[status] => 1
[created] => 2015-06-17 12:03:19
[updated] => 2015-06-18 13:05:16
)
[Category] => Array
(
[id] => 13
[user_id] => 2
[category_name] => Soft Drink juices
[category_image] =>
[status] => 1
[created] => 2015-06-17 11:15:33
[updated] => 2015-06-18 18:46:03
)
[Storeproduct] => Array
(
[0] => Array
(
[id] => 2
[product_id] => 11
[store_id] => 2
[details] => Real Mix Fruit Juice(200 litre)
[mrp] => 20
[selling_price] => 18
[discount] => 10
[price_difference] => 2
[is_deal] => 0
[deal_start_date] =>
[deal_end_date] =>
[status] => 1
[created] => 1434613767
[updated] => 1434613767
)
[1] => Array
(
[id] => 29
[product_id] => 11
[store_id] => 1
[details] => Real Mix Fruit Juice
[mrp] => 10
[selling_price] => 10
[discount] => 0
[price_difference] => 0
[is_deal] => 0
[deal_start_date] =>
[deal_end_date] =>
[status] => 1
[created] => 1435062192
[updated] => 1435123348
)
)
)
[8] => Array
(
[Product] => Array
(
[id] => 14
[user_id] => 2
[category_id] => 13
[name] => Real Apple Juice
[weight] => 1
[measurement] => ml
[image] =>
[status] => 1
[created] => 2015-06-18 13:06:44
[updated] => 0000-00-00 00:00:00
)
[Category] => Array
(
[id] => 13
[user_id] => 2
[category_name] => Soft Drink juices
[category_image] =>
[status] => 1
[created] => 2015-06-17 11:15:33
[updated] => 2015-06-18 18:46:03
)
[Storeproduct] => Array
(
[0] => Array
(
[id] => 24
[product_id] => 14
[store_id] => 2
[details] =>
[mrp] => 10
[selling_price] => 10
[discount] => 0
[price_difference] => 0
[is_deal] => 0
[deal_start_date] =>
[deal_end_date] =>
[status] => 1
[created] => 1435055411
[updated] => 1435055411
)
)
)
)
In the above array there are two same category array .I would like merge the same category array records
I need a output like
Category => array(
//category data,
Products=>array(//product data,
Storeproducts =>array(
//Storeproducts data
)
)
)
PHP is pretty well documented and you can find all of the Array sorting methods on this page.
There are some good examples in the comments as well - all you need to do is to sort the array by category and you are done.

group by data in left join

I have two tables: orders and product_orders
there are one id in orders table. i.e: 9
and order_id(as foreign key) in product_orders repeated 3 times. So I want this three entry in product_orders table with one entry in orders table.
My query is:
SELECT orders.*,order_products.* FROM orders LEFT JOIN order_products ON orders.id=order_products.order_id
this gives :
Array
(
[0] => Array
(
[orders] => Array
(
[id] => 9
[name] => Abdus Sattar Bhuiyan
[email] => sattar.kuet#gmail.com
[mobile] => 01673050495
[alt_mobile] => 01818953250
[city_id] => 2
[location_id] => 5
[status] => No contact
[chashed] => NO
[created] => 2015-06-27 12:49:34
[modified] => 2015-06-27 12:49:34
[comment] =>
)
[order_products] => Array
(
[id] => 2
[order_id] => 9
[product_id] => 1
[pieces] => 1
)
)
[1] => Array
(
[orders] => Array
(
[id] => 9
[name] => Abdus Sattar Bhuiyan
[email] => sattar.kuet#gmail.com
[mobile] => 01673050495
[alt_mobile] => 01818953250
[city_id] => 2
[location_id] => 5
[status] => No contact
[chashed] => NO
[created] => 2015-06-27 12:49:34
[modified] => 2015-06-27 12:49:34
[comment] =>
)
[order_products] => Array
(
[id] => 3
[order_id] => 9
[product_id] => 2
[pieces] => 1
)
)
[2] => Array
(
[orders] => Array
(
[id] => 9
[name] => Abdus Sattar Bhuiyan
[email] => sattar.kuet#gmail.com
[mobile] => 01673050495
[alt_mobile] => 01818953250
[city_id] => 2
[location_id] => 5
[status] => No contact
[chashed] => NO
[created] => 2015-06-27 12:49:34
[modified] => 2015-06-27 12:49:34
[comment] =>
)
[order_products] => Array
(
[id] => 4
[order_id] => 9
[product_id] => 3
[pieces] => 1
)
)
)
My expected result is:
Array
(
[0] => Array
(
[orders] => Array
(
[id] => 9
[name] => Abdus Sattar Bhuiyan
[email] => sattar.kuet#gmail.com
[mobile] => 01673050495
[alt_mobile] => 01818953250
[city_id] => 2
[location_id] => 5
[status] => No contact
[chashed] => NO
[created] => 2015-06-27 12:49:34
[modified] => 2015-06-27 12:49:34
[comment] =>
)
[order_products] => Array
(
[0] => Array(
[id] => 2
[order_id] => 9
[product_id] => 1
[pieces] => 1
)
[1] => Array(
[id] => 3
[order_id] => 9
[product_id] => 2
[pieces] => 1
)
[2] => Array(
[id] => 4
[order_id] => 9
[product_id] => 3
[pieces] => 1
)
)
)
)
I used GROUP BY orders.id. But no luck.
You are basically expecting a result that is not possible to obtain with a SQL query: you want a hierarchical structure, with a single order and a set of order_product for that order, while the query returns a flat table, with one row for each order together with the information of a different order_product. This is the way in which SQL works.
A way to solve your problem is to do a sort of post-processing in php, after getting all the rows, group all of them that have the same order part, and produce a new array for the order_product part related to that order.

Zend paginator not working properly when array format is not as it should be

Hi my zend paginator works well when the $business_list array format is like below.
but when the array format changes it displays only one page instead of many pages.
$paginator = Zend_Paginator::factory($business_list);
Array
(
[0] => Array
(
[id] => 216
[userid] => 141
[title] => first req
[image] =>
[logo] =>
[description] =>
this is the first requirment
[date] => 2012-06-12 10:31:01
[area] => 1
[budget] => 1
[type] => 1
[status] => 1
[CmBusinessSection] => Array
(
[0] => Array
(
[id] => 315
[business_id] => 216
[section_id] => 1
[subsection_id] => 13
[description] =>
)
[1] => Array
(
[id] => 316
[business_id] => 216
[section_id] => 3
[subsection_id] => 14
[description] =>
)
[2] => Array
(
[id] => 317
[business_id] => 216
[section_id] => 4
[subsection_id] => 15
[description] =>
)
)
[CmUser] => Array
(
[id] => 141
[username] => venki
[password] =>
[firstname] => venkatesh
[lastname] => abus
[image] => 54winter.jpg
[email] => xxx#xx.com
[phone] => 23423452
[group_id] => 2
[status] =>
[registered_date] => 2012-06-04 06:32:58
[last_visit] => 0000-00-00 00:00:00
[is_active] => 1
[subscribe] => 1
)
)
[1] => Array
(
[id] => 214
[userid] => 98
[title] => gopicontractor
[image] => 54bluehills.jpg
[logo] => 239waterlilies.jpg
[description] =>
TIt uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is
[date] => 2012-06-11 12:18:58
[area] => 1
[budget] => 1
[type] => 3
[status] => 1
[CmBusinessSection] => Array
(
[0] => Array
(
[id] => 305
[business_id] => 214
[section_id] => 1
[subsection_id] => 5
[description] =>
)
[1] => Array
(
[id] => 306
[business_id] => 214
[section_id] => 1
[subsection_id] => 6
[description] =>
)
[2] => Array
(
[id] => 307
[business_id] => 214
[section_id] => 3
[subsection_id] => 1
[description] =>
)
[3] => Array
(
[id] => 308
[business_id] => 214
[section_id] => 4
[subsection_id] => 9
[description] =>
)
)
[CmUser] => Array
(
[id] => 98
[username] => gopi.s
[password] =>
[firstname] => venkatesh
[lastname] => franc
[image] =>
[email] => ss#ss.com
[phone] => 23423452
[group_id] => 3
[status] =>
[registered_date] => 2012-05-16 12:36:57
[last_visit] => 0000-00-00 00:00:00
[is_active] => 1
[subscribe] => 1
)
)
)
the above array format displays paginatin correctly.
This is the array that displays only one page in pagination.
Zend_Paginator Object
(
[_cacheEnabled:protected] => 1
[_adapter:protected] => Zend_Paginator_Adapter_Array Object
(
[_array:protected] => Array
(
[0] => Array
(
[id] => 89
[username] => xx
[password] => xx
[firstname] => xx
[lastname] => xx
[image] =>
[email] => xx#ymail.com
[phone] => 2342345
[group_id] => 2
[status] => offline
[registered_date] => 2012-05-15 10:58:53
[last_visit] =>
[is_active] => 1
[subscribe] => 0
[CmBusiness] => Array
(
[0] => Array
(
[id] => 204
[userid] => 89
[title] => xxhousing
[image] => 760067.jpg
[logo] => xx_818f3c97e6_o.jpg
[description] => xx
[date] => 2012-05-31 13:36:17
[area] => 1
[budget] => 1
[type] => 1
[status] => 1
[CmAmount] => Array
(
[id] => 1
[amount] => 1000-1500
[status] => 1
)
[CmBusinessSection] => Array
(
[0] => Array
(
[id] => 251
[business_id] => 204
[section_id] => 1
[subsection_id] => 6
[description] => xx
)
[1] => Array
(
[id] => 252
[business_id] => 204
[section_id] => 3
[subsection_id] => 2
[description] => xx
)
[2] => Array
(
[id] => 253
[business_id] => 204
[section_id] => 3
[subsection_id] => 4
[description] => xx
)
[3] => Array
(
[id] => 254
[business_id] => 204
[section_id] => 4
[subsection_id] => 9
[description] => xx
)
)
[CmArea] => Array
(
[id] => 1
[area] => manchester
[status] => 1
)
[CmType] => Array
(
[id] => 1
[type] => Personal business
[status] => 1
)
)
[1] => Array
(
[id] => 205
[userid] => 89
[title] => xx
[image] => 41217850-desktop-wallpapers-new-windows-xp.jpg
[logo] => 356anger_n.jpg
[description] => xx
[date] => 2012-05-31 13:37:15
[area] => 1
[budget] => 1
[type] => 3
[status] => 1
[CmAmount] => Array
(
[id] => 1
[amount] => 1000-1500
[status] => 1
)
[CmBusinessSection] => Array
(
[0] => Array
(
[id] => 255
[business_id] => 205
[section_id] => 1
[subsection_id] => 6
[description] =>xx
)
[1] => Array
(
[id] => 256
[business_id] => 205
[section_id] => 3
[subsection_id] => 1
[description] => xx
)
[2] => Array
(
[id] => 257
[business_id] => 205
[section_id] => 3
[subsection_id] => 2
[description] => xx
)
[3] => Array
(
[id] => 258
[business_id] => 205
[section_id] => 4
[subsection_id] => 10
[description] => xx
)
)
[CmArea] => Array
(
[id] => 1
[area] => manchester
[status] => 1
)
[CmType] => Array
(
[id] => 3
[type] => Bilde companies
[status] => 1
)
)
[2] => Array
(
[id] => 206
[userid] => 89
[title] => Nuestros recursos
[image] =>
[logo] =>
[description] => xx
[date] => 2012-05-31 13:38:04
[area] => 1
[budget] => 1
[type] => 4
[status] => 1
[CmAmount] => Array
(
[id] => 1
[amount] => 1000-1500
[status] => 1
)
[CmBusinessSection] => Array
(
[0] => Array
(
[id] => 259
[business_id] => 206
[section_id] => 1
[subsection_id] => 5
[description] =>
)
[1] => Array
(
[id] => 260
[business_id] => 206
[section_id] => 1
[subsection_id] => 6
[description] =>
)
[2] => Array
(
[id] => 261
[business_id] => 206
[section_id] => 3
[subsection_id] => 2
[description] =>
)
[3] => Array
(
[id] => 262
[business_id] => 206
[section_id] => 4
[subsection_id] => 10
[description] =>
)
)
[CmArea] => Array
(
[id] => 1
[area] => manchester
[status] => 1
)
[CmType] => Array
(
[id] => 4
[type] => Designer
[status] => 1
)
)
)
)
)
[_count:protected] => 1
)
[_currentItemCount:protected] =>
[_currentItems:protected] =>
[_currentPageNumber:protected] => 1
[_filter:protected] =>
[_itemCountPerPage:protected] => 2
[_pageCount:protected] => 1
[_pageRange:protected] =>
[_pages:protected] =>
[_view:protected] =>
)

Categories