Presently m working with CakePhp..i got some problem with combining two array and prepare for a json encoded array.. i used array_merge() property but its not working.. how can i encoded both of these two array..
M doing like this :
return json_encode(array_merge ($product_list,$price_list));
i have two php array as follows :
array 1:
Array
(
[0] => Array
(
[PriceList] => Array
(
[price_id] => 2
[price_name] => abc
[date_time] => 2015-07-06 16:22:56
[dealer_type] => Dealer
[purpose] => dealer
[status] => ACTIVE
)
)
[1] => Array
(
[PriceList] => Array
(
[price_id] => 3
[price_name] => xyz
[date_time] => 2015-07-06 16:22:56
[dealer_type] => Dealer
[purpose] => dealer
[status] => ACTIVE
)
)
)
array 2:
Array
(
[0] => Array
(
[Product] => Array
(
[cat_id] => 1
[subcat_id] => 3
[brand_id] => 1
[p_code] => PP12567
[name] => akai
[model_no] =>
[specification] => color tv
[color] =>
[quality] =>
[size] =>
[p_unavail] => 1
[demo_avail] => 0
[brochure] =>
[status] => active
)
[ProductPrice] => Array
(
[id] => 154
[p_code] => PP12567
[price_id] => 1
[quantity] => 233
[purchase_price] => 344.00
[selling_price] => 44.00
[discount_price] => 33.00
[tax] => 5.00
[datetime] => 2015-07-23 15:47:11
)
[ProductSubCategory] => Array
(
[subcat_id] => 3
[cat_id] => 1
[subcat_name] => samsung
[status] => active
)
[ProductCategory] => Array
(
[cat_id] => 1
[cat_name] => Electronics
[cat_type] => Product
[status] => active
)
)
[1] => Array
(
[Product] => Array
(
[cat_id] => 1
[subcat_id] => 4
[brand_id] => 1
[p_code] => PBC-676767
[name] => music
[model_no] => 33
[specification] =>
[color] =>
[quality] =>
[size] =>
[p_unavail] => 0
[demo_avail] => 0
[brochure] =>
[status] => active
)
[ProductPrice] => Array
(
[id] => 156
[p_code] => PBC-676767
[price_id] => 1
[quantity] => 767
[purchase_price] => 54.00
[selling_price] => 55.00
[discount_price] => 22.00
[tax] => 3.00
[datetime] => 2015-07-23 15:47:11
)
[ProductSubCategory] => Array
(
[subcat_id] => 4
[cat_id] => 1
[subcat_name] => sony
[status] => active
)
[ProductCategory] => Array
(
[cat_id] => 1
[cat_name] => Electronics
[cat_type] => Product
[status] => active
)
)
)
how to combine these two array into one and encoded into a json array..
You have to use array_merge but not directly on array1 and array2:
$toEncodeArray = [array_merge ($array1[0], $array2[0])] ;
If you only want the associative array (without the wrapping array), simply do:
$toEncodeArray = array_merge ($array1[0], $array2[0]) ;
Related
I have two Arrays 1st Array give me a role form Roles table and second array give me the data using this role_id key.
When i pass the array to view how can i get Role that is from first foreach().
This is my
SettingController.php
public function index()
{
$users = User::with('roles')->get()->all();
$access_names = AccessName::all();
$modules = Module::all();
$entries = Entry::all();
$general_settings = Setting::all()->first();
$module_permissions = ModulePermission::get()->toArray();
$roles = Role::get();
$num_roles = count($roles);
$data = 'roles';
foreach ($roles as $role){
foreach ($module_permissions as $permissions){
if($role['id'] == $permissions['role_id']){
$roles_data[$role['name']][] = $permissions;
}
}
}
return view('backend.setting.index', compact(['general_settings', 'roles', 'users', 'access_names', 'roles_data','modules','entries']));
}
My output of this code is like this
Array
(
[Admin] => Array
(
[1] => Array
(
[id] => 179
[user_id] => 1
[role_id] => 1
[access_name_id] => 2
[module_permission_id] => 1
[entry_type] => own
[status] => 0
[created_at] => 2019-08-22 04:45:14
[updated_at] => 2019-08-22 04:45:14
)
)
[User] => Array
(
[0] => Array
(
[id] => 206
[user_id] => 2
[role_id] => 2
[access_name_id] => 1
[module_permission_id] => 1
[entry_type] => own
[status] => 1
[created_at] => 2019-08-22 05:09:40
[updated_at] => 2019-08-22 05:09:40
)
)
)
If i can access data from this then very well other wise i make a new array like this from i can access this by a new array that is data so it is easy to check that
I also tried this but this is not working properly
foreach ($roles as $role){
foreach ($module_permissions as $permissions){
if($role['id'] == $permissions['role_id']){
$roles_data[$role['name']][] = $permissions;
$array['data'] = $roles_data;
}
}
}
But If output come like this that is also very good
Array
(
[data]=>array
(
[Admin] => Array
(
[0] => Array
(
[id] => 179
[user_id] => 1
[role_id] => 1
[access_name_id] => 2
[module_permission_id] => 1
[entry_type] => own
[status] => 0
[created_at] => 2019-08-22 04:45:14
[updated_at] => 2019-08-22 04:45:14
)
)
[User] => Array
(
[0] => Array
(
[id] => 206
[user_id] => 2
[role_id] => 2
[access_name_id] => 1
[module_permission_id] => 1
[entry_type] => own
[status] => 1
[created_at] => 2019-08-22 05:09:40
[updated_at] => 2019-08-22 05:09:40
)
)
)
)
In view i want to do like this.
view.blade.php
if($role->name == 'data['Admin']'){
//then do this
}
elseif($role->name == 'data['User']'){
// do this
}
else{
// do this
}
And i also want to this dynamic what can i do to make dynamic i not use 'admin' and 'user' because if i have many roles it is difficult to handle.
Thanks.................
i have two arrays and i want two merge using the same value within each array..
the first array is :
[0] => Array
(
[id] => 1
[uid] => 0090000157
[cid] => 0090000007
[extension] => 202
[secret] => Myojyo42f!
[leader] => 1
[simultaneous] =>
[confbridge_id] => 2
[created_at] => 2015-07-26 12:20:20
[updated_at] => 2015-07-26 12:20:20
)
[1] => Array
(
[id] => 2
[uid] => 0090000159
[cid] => 0090000007
[extension] =>
[secret] => Myojyo42f!
[leader] =>
[simultaneous] =>
[confbridge_id] => 2
[created_at] => 2015-07-26 14:23:41
[updated_at] => 2015-07-26 14:23:41
)
)
and the second array is:
Array
(
[0] => Array
(
[_id] => 55b52f4c2bab38fc63b6272a
[event] => ConfbridgeJoin
[channel] => SIP/peer_voip301confbridge-0000001b
[uniqueid] => 1437937478.63
[conference] => 0090000156
[calleridnum] => 0090000157
[calleridname] => 0090000157
[__v] => 0
[sipSetting] => Array
(
[accountcode] =>
[accountcode_naisen] => 202
[extentype] => 0
[extenrealname] =>
[name] => 0090000157
[secret] => Myojyo42f!
[username] => 0090000157
[context] => innercall_xdigit
[gid] => 101
[cid] => 0090000007
)
)
[1] => Array
(
[_id] => 55b53a2e2bab38fc63b6272b
[event] => ConfbridgeJoin
[channel] => SIP/peer_voip301confbridge-0000001c
[uniqueid] => 1437940260.66
[conference] => 0090000156
[calleridnum] => 0090000158
[calleridname] => UID2
[__v] => 0
[sipSetting] => Array
(
[accountcode] =>
[accountcode_naisen] => 203
[extentype] => 0
[extenrealname] =>
[name] => 0090000158
[secret] => Myojyo42f!
[username] => 0090000158
[context] => innercall_xdigit
[gid] => 101
[cid] => 0090000007
)
)
)
i want to merge array with the same value for example :
first array has = [uid] => 0090000157
second array has = [calleridnum] => 0090000157
is it possible to merge them?
this is my code
{foreach from=$participants item=participant key=p }
{foreach from=$conference_participants item=conference_participant key=c}
{if$participants.calleridnum == $conference_participants.uid}
//how to get data here ?
{/if}
{/foreach}
{/foreach}
Could this be what you're looking for?
Sorry for all the changes, I should have tested it... grr
(I've put this in PHPFiddle:
<pre>
<?php
$participants = [
[ 'calleridnum' => 1,
'test' => 'yay'
]
];
$conferance_participants = [
[ 'uid' => 1,
'test' => 'yay2',
'dit' => 'deze'
]
];
foreach ($participants as $participant=>$p) {
foreach ($conferance_participants as $conferance_participant=>$c) {
if ($p['calleridnum'] == $c['uid']) {
// ID's match do the magic here
foreach ( $c as $key=>$val ) {
if (!isset($p[$key])) {
// Value is new, copy the conferance_participant to the participant
$participants[$participant][$key] = $val;
}
} // Merging data
} // If: Match
}
}
print_r( $participants );
?>
)
How do I scoop just the '$reference_cart_id' variable from this session_cart_array so i can query db for other matching id's that belong to this customer? When i loop back through an undefined error comes up for reference_id & reference_cart_id.
cartOutput --Array
(
[0] => Array
(
[item_id] => 133
[quantity] => 1
[size] => MED
[color] => Black
[username] => medallion9
[reference_cart_id] => DU3ZWRjNTkwNGYy
[reference_id] => 6cefe27
)
[1] => Array
(
[item_id] => 134
[quantity] => 1
[size] => LG
[color] => Camel-501
[username] => medallion9
[reference_cart_id] => DU3ZWRjNTkwNGYy
[reference_id] => 6cefe27
)
)
You can use array_map (http://php.net/manual/en/function.array-map.php):
$idArray = array_map(function($a){ return $a['reference_cart_id']; },$cartArray);
I am working on Reporting of the Postal service Project and i wanted to display data with the help of pagination . i know we can overwrite pagination function in model . i have tried it but didn't work for me.
I have BillReport Model where i have created function. Below is my custom query which is showing Multiple Bills against one payment means Payment hasMany Bills. I can paginate Payment but i wanted to paginate Bill wise.
I have mapped the bills and payments in Billpaymentmap table and from that table i am getting array of below query.
I want to paginate related model which is associated with Payment . Payment Hasmany Bill.
$reversal = $this->query("SELECT Pay.*,C.id,C.name,U.id,U.username,Bill.account_no,Bill.id, Pay.*,PMap.data,PMap.paid_amount FROM dbo_payments As Pay INNER JOIN dbo_reverse_payments As RPay ON RPay.payment_id = Pay.id INNER JOIN dbo_payment_bill_maps As PMap ON PMap.payment_id = RPay.payment_id INNER JOIN dbo_users U ON U.id = Pay.cashier_id INNER JOIN dbo_clients As C ON C.id = U.client_id INNER JOIN dbo_bills As Bill ON Bill.id = PMap.bill_id WHERE Pay.reversal = 1 and $conditions ");
Array
(
[0] => Array
(
[Pay] => Array
(
[id] => 10
[location_id] => 133
[cashier_id] => 5
[client_id] => 2
[dealer_id] => 31
[receipt_no] => 58130
[pay_date] => 2015-02-18 12:42:28
[amount_paid] => 3715
[total_paid] => 3715
[change_due] => 0
[pay_method] => CA
[bank] =>
[ref_no] =>
[payment_type] => Bill
[reversal_fee] =>
[reversal_code] =>
[reversal] => 1
[reversal_date] =>
[reversed_by_id] =>
)
[C] => Array
(
[id] => 31
[name] => GAMPOST
)
[U] => Array
(
[id] => 5
[username] => admin
)
[Bill] => Array
(
[account_no] => 1910009
[id] => 1037079
)
[RPay] => Array
(
[id] => 1
[payment_id] => 10
[user_id] => 5
[reason] => LIC
[reversal_fee] =>
[created] => 2015-02-18 13:06:28
)
[PMap] => Array
(
[data] => a:3:{s:4:"name";s:6:"Ganesh";s:7:"address";s:17:"Test address 1sdk";s:11:"paymentType";s:4:"BILL";}
[paid_amount] => 3215.00
)
)
[1] => Array
(
[Pay] => Array
(
[id] => 10
[location_id] => 133
[cashier_id] => 5
[client_id] => 2
[dealer_id] => 31
[receipt_no] => 58130
[pay_date] => 2015-02-18 12:42:28
[amount_paid] => 3715
[total_paid] => 3715
[change_due] => 0
[pay_method] => CA
[bank] =>
[ref_no] =>
[payment_type] => Bill
[reversal_fee] =>
[reversal_code] =>
[reversal] => 1
[reversal_date] =>
[reversed_by_id] =>
)
[C] => Array
(
[id] => 31
[name] => GAMPOST
)
[U] => Array
(
[id] => 5
[username] => admin
)
[Bill] => Array
(
[account_no] => 546865468
[id] => 1037162
)
[RPay] => Array
(
[id] => 1
[payment_id] => 10
[user_id] => 5
[reason] => LIC
[reversal_fee] =>
[created] => 2015-02-18 13:06:28
)
[PMap] => Array
(
[data] => a:3:{s:4:"name";s:38:"Amit Trivedi Trivedi Trivedi Trivedi";s:7:"address";s:6:"Mamura";s:11:"paymentType";s:4:"BILL";}
[paid_amount] => 500.00
)
)
[2] => Array
(
[Pay] => Array
(
[id] => 7
[location_id] => 133
[cashier_id] => 5
[client_id] => 2
[dealer_id] => 31
[receipt_no] => 82053
[pay_date] => 2015-02-18 12:29:21
[amount_paid] => 8380
[total_paid] => 8380
[change_due] => 0
[pay_method] => CA
[bank] =>
[ref_no] =>
[payment_type] => Bill
[reversal_fee] =>
[reversal_code] =>
[reversal] => 1
[reversal_date] =>
[reversed_by_id] =>
)
[C] => Array
(
[id] => 31
[name] => GAMPOST
)
[U] => Array
(
[id] => 5
[username] => admin
)
[Bill] => Array
(
[account_no] => 1910001
[id] => 1037071
)
[RPay] => Array
(
[id] => 2
[payment_id] => 7
[user_id] => 5
[reason] => LF
[reversal_fee] =>
[created] => 2015-02-18 13:06:43
)
[PMap] => Array
(
[data] => a:3:{s:4:"name";s:6:"Tushar";s:7:"address";s:17:"Test address 1sdk";s:11:"paymentType";s:4:"BILL";}
[paid_amount] => 4665.00
)
)
[3] => Array
(
[Pay] => Array
(
[id] => 7
[location_id] => 133
[cashier_id] => 5
[client_id] => 2
[dealer_id] => 31
[receipt_no] => 82053
[pay_date] => 2015-02-18 12:29:21
[amount_paid] => 8380
[total_paid] => 8380
[change_due] => 0
[pay_method] => CA
[bank] =>
[ref_no] =>
[payment_type] => Bill
[reversal_fee] =>
[reversal_code] =>
[reversal] => 1
[reversal_date] =>
[reversed_by_id] =>
)
[C] => Array
(
[id] => 31
[name] => GAMPOST
)
[U] => Array
(
[id] => 5
[username] => admin
)
[Bill] => Array
(
[account_no] => 1910009
[id] => 1037079
)
[RPay] => Array
(
[id] => 2
[payment_id] => 7
[user_id] => 5
[reason] => LF
[reversal_fee] =>
[created] => 2015-02-18 13:06:43
)
[PMap] => Array
(
[data] => a:3:{s:4:"name";s:6:"Ganesh";s:7:"address";s:17:"Test address 1sdk";s:11:"paymentType";s:4:"BILL";}
[paid_amount] => 3215.00
)
)
[4] => Array
(
[Pay] => Array
(
[id] => 7
[location_id] => 133
[cashier_id] => 5
[client_id] => 2
[dealer_id] => 31
[receipt_no] => 82053
[pay_date] => 2015-02-18 12:29:21
[amount_paid] => 8380
[total_paid] => 8380
[change_due] => 0
[pay_method] => CA
[bank] =>
[ref_no] =>
[payment_type] => Bill
[reversal_fee] =>
[reversal_code] =>
[reversal] => 1
[reversal_date] =>
[reversed_by_id] =>
)
[C] => Array
(
[id] => 31
[name] => GAMPOST
)
[U] => Array
(
[id] => 5
[username] => admin
)
[Bill] => Array
(
[account_no] => 546865468
[id] => 1037162
)
[RPay] => Array
(
[id] => 2
[payment_id] => 7
[user_id] => 5
[reason] => LF
[reversal_fee] =>
[created] => 2015-02-18 13:06:43
)
[PMap] => Array
(
[data] => a:3:{s:4:"name";s:38:"Amit Trivedi Trivedi Trivedi Trivedi";s:7:"address";s:6:"Mamura";s:11:"paymentType";s:4:"BILL";}
[paid_amount] => 500.00
)
)
)
I have googled but i am not getting my answer. Can anyone please help me on this.
Thanks for reply.
I went through below link . i have given limit => 3 . it is giving me data upto 3 for Payments Not for Bills which are multiple against one Payment.
I need to paginate 'PaymentBillMap' data .
public $paginate = array('limit'=>'3',
'order'=>'Payment.pay_date',
'fields'=>array('Payment.id','Payment.location_id','Payment.dealer_id'));
public function trans_list_service(){
$params = $this->__commonopr();
$this->loadModel('Payment');
$this->loadModel('PaymentBillMap');
$conditions = array('Payment.location_id ' => 133);
// apply the custom conditions to the pagination
$payments = $this->paginate('Payment',$conditions);
$this->set('payments', $payments);
pr($payments);
}
Custom Query Pagination Cakephp
Array
(
[0] => Array
(
[Payment] => Array
(
[id] => 1
[location_id] => 133
[dealer_id] => 31
)
[PaymentBillMap] => Array
(
[0] => Array
(
[payment_id] => 1
[bill_id] => 1037153
[paid_amount] => 4656.00
[payment_type] => BILL
[trans_no] => 24862
[data] => a:3:{s:4:"name";s:6:"Ganesh";s:7:"address";s:7:"Dholpur";s:11:"paymentType";s:4:"BILL";}
)
[1] => Array
(
[payment_id] => 1
[bill_id] => 1037154
[paid_amount] => 4665.00
[payment_type] => BILL
[trans_no] => 48280
[data] => a:3:{s:4:"name";s:5:"AMITA";s:7:"address";s:10:"Ganganagar";s:11:"paymentType";s:4:"BILL";}
)
[2] => Array
(
[payment_id] => 1
[bill_id] => 1037155
[paid_amount] => 5787.00
[payment_type] => BILL
[trans_no] => 45996
[data] => a:3:{s:4:"name";s:9:"duryodhan";s:7:"address";s:5:"Jalor";s:11:"paymentType";s:4:"BILL";}
)
[3] => Array
(
[payment_id] => 1
[bill_id] => 1037156
[paid_amount] => 6688.00
[payment_type] => BILL
[trans_no] => 64019
[data] => a:3:{s:4:"name";s:6:"Dharaj";s:7:"address";s:8:"Jhalawar";s:11:"paymentType";s:4:"BILL";}
)
[4] => Array
(
[payment_id] => 1
[bill_id] => 1037157
[paid_amount] => 8795.00
[payment_type] => BILL
[trans_no] => 21308
[data] => a:3:{s:4:"name";s:4:"Amit";s:7:"address";s:9:"Jhunjhunu";s:11:"paymentType";s:4:"BILL";}
)
[5] => Array
(
[payment_id] => 1
[bill_id] => 1037158
[paid_amount] => 5654.00
[payment_type] => BILL
[trans_no] => 10980
[data] => a:3:{s:4:"name";s:5:"Gaesh";s:7:"address";s:4:"Pali";s:11:"paymentType";s:4:"BILL";}
)
[6] => Array
(
[payment_id] => 1
[bill_id] => 1037159
[paid_amount] => 3456.00
[payment_type] => BILL
[trans_no] => 79988
[data] => a:3:{s:4:"name";s:4:"Jitu";s:7:"address";s:14:"Sawai Madhopur";s:11:"paymentType";s:4:"BILL";}
)
[7] => Array
(
[payment_id] => 1
[bill_id] => 1037160
[paid_amount] => 4664.00
[payment_type] => BILL
[trans_no] => 26314
[data] => a:3:{s:4:"name";s:6:"Rajesh";s:7:"address";s:6:"Sirohi";s:11:"paymentType";s:4:"BILL";}
)
[8] => Array
(
[payment_id] => 1
[bill_id] => 1037161
[paid_amount] => 3565.00
[payment_type] => BILL
[trans_no] => 40148
[data] => a:3:{s:4:"name";s:4:"Gani";s:7:"address";s:5:"Baran";s:11:"paymentType";s:4:"BILL";}
)
[9] => Array
(
[payment_id] => 1
[bill_id] => 1037148
[paid_amount] => 3442.00
[payment_type] => BILL
[trans_no] => 48235
[data] => a:3:{s:4:"name";s:4:"Jitu";s:7:"address";s:5:"Ajmer";s:11:"paymentType";s:4:"BILL";}
)
[10] => Array
(
[payment_id] => 1
[bill_id] => 1037149
[paid_amount] => 4335.00
[payment_type] => BILL
[trans_no] => 71496
[data] => a:3:{s:4:"name";s:4:"amer";s:7:"address";s:5:"Alwar";s:11:"paymentType";s:4:"BILL";}
)
[11] => Array
(
[payment_id] => 1
[bill_id] => 1037150
[paid_amount] => 3535.00
[payment_type] => BILL
[trans_no] => 93135
[data] => a:3:{s:4:"name";s:6:"Dilip[";s:7:"address";s:9:"Bharatpur";s:11:"paymentType";s:4:"BILL";}
)
[12] => Array
(
[payment_id] => 1
[bill_id] => 1037151
[paid_amount] => 6453.00
[payment_type] => BILL
[trans_no] => 46714
[data] => a:3:{s:4:"name";s:7:"Suvarna";s:7:"address";s:11:"Chittorgarh";s:11:"paymentType";s:4:"BILL";}
)
[13] => Array
(
[payment_id] => 1
[bill_id] => 1037152
[paid_amount] => 5323.00
[payment_type] => BILL
[trans_no] => 43007
[data] => a:3:{s:4:"name";s:5:"Datta";s:7:"address";s:5:"Churu";s:11:"paymentType";s:4:"BILL";}
)
[14] => Array
(
[payment_id] => 1
[bill_id] => 1037136
[paid_amount] => 6456.00
[payment_type] => BILL
[trans_no] => 27701
[data] => a:3:{s:4:"name";s:6:"Faizan";s:7:"address";s:9:"Dungarpur";s:11:"paymentType";s:4:"BILL";}
)
[15] => Array
(
[payment_id] => 1
[bill_id] => 1037137
[paid_amount] => 7657.00
[payment_type] => BILL
[trans_no] => 29162
[data] => a:3:{s:4:"name";s:6:"Shamli";s:7:"address";s:7:"Jodhpur";s:11:"paymentType";s:4:"BILL";}
)
[16] => Array
(
[payment_id] => 1
[bill_id] => 1037138
[paid_amount] => 8688.00
[payment_type] => BILL
[trans_no] => 77181
[data] => a:3:{s:4:"name";s:6:"Tushat";s:7:"address";s:4:"Kota";s:11:"paymentType";s:4:"BILL";}
)
[17] => Array
(
[payment_id] => 1
[bill_id] => 1037139
[paid_amount] => 4657.00
[payment_type] => BILL
[trans_no] => 75049
[data] => a:3:{s:4:"name";s:5:"Danav";s:7:"address";s:7:"Udaipur";s:11:"paymentType";s:4:"BILL";}
)
[18] => Array
(
[payment_id] => 1
[bill_id] => 1037140
[paid_amount] => 6886.00
[payment_type] => BILL
[trans_no] => 48850
[data] => a:3:{s:4:"name";s:6:"Kailas";s:7:"address";s:7:"Bikaner";s:11:"paymentType";s:4:"BILL";}
)
[19] => Array
(
[payment_id] => 1
[bill_id] => 1037141
[paid_amount] => 7965.00
[payment_type] => BILL
[trans_no] => 11684
[data] => a:3:{s:4:"name";s:7:"Paravat";s:7:"address";s:5:"Dausa";s:11:"paymentType";s:4:"BILL";}
)
)
)
[1] => Array
(
[Payment] => Array
(
[id] => 2
[location_id] => 133
[dealer_id] => 31
)
[PaymentBillMap] => Array
(
[0] => Array
(
[payment_id] => 2
[bill_id] => 1037162
[paid_amount] => 500.00
[payment_type] => BILL
[trans_no] => 62066
[data] => a:3:{s:4:"name";s:37:"Amit Trivedi Trivedi Trivedi Trivedi";s:7:"address";s:6:"Mamura";s:11:"paymentType";s:4:"BILL";}
)
[1] => Array
(
[payment_id] => 2
[bill_id] => 1037079
[paid_amount] => 3215.00
[payment_type] => BILL
[trans_no] => 41810
[data] => a:3:{s:4:"name";s:6:"Ganesh";s:7:"address";s:17:"Test address 1sdk";s:11:"paymentType";s:4:"BILL";}
)
)
)
[2] => Array
(
[Payment] => Array
(
[id] => 3
[location_id] => 133
[dealer_id] => 31
)
[PaymentBillMap] => Array
(
[0] => Array
(
[payment_id] => 3
[bill_id] => 1037162
[paid_amount] => 500.00
[payment_type] => BILL
[trans_no] => 74439
[data] => a:3:{s:4:"name";s:38:"Amit Trivedi Trivedi Trivedi Trivedi";s:7:"address";s:6:"Mamura";s:11:"paymentType";s:4:"BILL";}
)
)
)
)
I have this array result and want to sort based on name
$arr = array
(0 => array
(
(name) => Medianas empresas
(count) => 17
[applied] =>
[url] => /es/index.php?option=com_virtuemart&view=category&Itemid=230&usage=Medianas+empresas
)
1 => array
(
[name] => Grandes empresas y gobierno
[count] => 8
[applied] =>
[url] => /es/index.php?option=com_virtuemart&view=category&Itemid=230&usage=Grandes+empresas+y+gobierno
)
2 => array
(
[name] => Microempresas
[count] => 9
[applied] =>
[url] => /es/index.php?option=com_virtuemart&view=category&Itemid=230&usage=Microempresas
)
)
The result should be like,
$arr = array
(
1 => array
(
[name] => Grandes empresas y gobierno
[count] => 8
[applied] =>
[url] => /es/index.php?option=com_virtuemart&view=category&Itemid=230&usage=Grandes+empresas+y+gobierno
)
0 => array
(
(name) => Medianas empresas
(count) => 17
[applied] =>
[url] => /es/index.php?option=com_virtuemart&view=category&Itemid=230&usage=Medianas+empresas
)
2 => array
(
[name] => Microempresas
[count] => 9
[applied] =>
[url] => /es/index.php?option=com_virtuemart&view=category&Itemid=230&usage=Microempresas
)
)
The desired result is in fact identical to the one you have, so, there is nothing to do.
If you confounded indices 0 and 1 in your desired result, just
sort($arr);
would do the job.