PHP Classes

Array

Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  Array  
Subject:Array
Summary:Need to compare same value in an array and make it as a array
Messages:2
Author:Ashraf
Date:2010-10-12 17:26:21
Update:2010-10-19 02:53:24
 

  1. Array   Reply   Report abuse  
Picture of Ashraf Ashraf - 2010-10-12 20:51:09
i have retrieved the records from mysql database as an double dimensional array which is give below

Array
(
[0] => Array
(
[0] => Array
(
[0] => 11
[BudgetHead] => Contingency
[1] => 1
[Ident] => 1
[2] => 11021001
[ProjectCode] => 11021001
[3] =>
[Department] =>
[4] => 11
[5] => 500
[Amount] => 500
[6] => csir/2010/101
[LetterNo] => csir/2010/101
[7] => 2010-09-27
[LetterDate] => 2010-09-27
[8] => Contingency
)
[1] => Array
(
[0] => 11
[BudgetHead] => Contingency
[1] => 6
[Ident] => 6
[2] => 11021001
[ProjectCode] => 11021001
[3] =>
[Department] =>
[4] => 11
[5] => 5000
[Amount] => 5000
[6] => hghg/2010
[LetterNo] => hghg/2010
[7] => 2010-09-28
[LetterDate] => 2010-09-28
[8] => Contingency
)

[2] => Array
(
[0] => 11
[BudgetHead] => Contingency
[1] => 11
[Ident] => 11
[2] => 11021001
[ProjectCode] => 11021001
[3] =>
[Department] =>
[4] => 11
[5] => 100000
[Amount] => 100000
[6] =>
[LetterNo] =>
[7] => 2010-10-10
[LetterDate] => 2010-10-10
[8] => Contingency
)
)
[1] => Array
(
[0] => Array
(
[0] => 15
[BudgetHead] => Equipment(Major)
[1] => 2
[Ident] => 2
[2] => 11021001
[ProjectCode] => 11021001
[3] =>
[Department] =>
[4] => 15
[5] => 1000
[Amount] => 1000
[6] => csir/2010/101
[LetterNo] => csir/2010/101
[7] => 2010-09-27
[LetterDate] => 2010-09-27
[8] => Equipment(Major)
)
[1] => Array
(
[0] => 15
[BudgetHead] => Equipment(Major)
[1] => 7
[Ident] => 7
[2] => 11021001
[ProjectCode] => 11021001
[3] =>
[Department] =>
[4] => 15
[5] => 10000
[Amount] => 10000
[6] => hghg/2010
[LetterNo] => hghg/2010
[7] => 2010-09-28
[LetterDate] => 2010-09-28
[8] => Equipment(Major)
)
)

[2] => Array
(
[0] => Array
(
[0] => 35
[BudgetHead] => Overhead Charges - Departments
[1] => 3
[Ident] => 3
[2] => 11021001
[ProjectCode] => 11021001
[3] =>
[Department] =>
[4] => 35
[5] => 1500
[Amount] => 1500
[6] => csir/2010/101
[LetterNo] => csir/2010/101
[7] => 2010-09-27
[LetterDate] => 2010-09-27
[8] => Overhead Charges - Departments
)
[1] => Array
(
[0] => 35
[BudgetHead] => Overhead Charges - Departments
[1] => 8
[Ident] => 8
[2] => 11021001
[ProjectCode] => 11021001
[3] =>
[Department] =>
[4] => 35
[5] => 15000
[Amount] => 15000
[6] => hghg/2010
[LetterNo] => hghg/2010
[7] => 2010-09-28
[LetterDate] => 2010-09-28
[8] => Overhead Charges - Departments
)
)
[3] => Array
(
[0] =>Array
(
[0] => 36
[BudgetHead] => Overhead Charges - University
[1] => 4
[Ident] => 4
[2] => 11021001
[ProjectCode] => 11021001
[3] =>
[Department] =>
[4] => 36
[5] => 2000
[Amount] => 2000
[6] => csir/2010/101
[LetterNo] => csir/2010/101
[7] => 2010-09-27
[LetterDate] => 2010-09-27
[8] => Overhead Charges – University
)
[1] => Array
(
[0] => 36
[BudgetHead] => Overhead Charges - University
[1] => 9
[Ident] => 9
[2] => 11021001
[ProjectCode] => 11021001
[3] =>
[Department] =>
[4] => 36
[5] => 20000
[Amount] => 20000
[6] => hghg/2010
[LetterNo] => hghg/2010
[7] => 2010-09-28
[LetterDate] => 2010-09-28
[8] => Overhead Charges - University
)
)

[4] => Array
(
[0] =>Array
(
[0] => 18
[BudgetHead] => Fellowship
[1] => 5
[Ident] => 5
[2] => 11021001
[ProjectCode] => 11021001
[3] =>
[Department] =>
[4] => 18
[5] => 2500
[Amount] => 2500
[6] => csir/2010/101
[LetterNo] => csir/2010/101
[7] => 2010-09-27
[LetterDate] => 2010-09-27
[8] => Fellowship
)
[10] => Array
(
[0] => 18
[BudgetHead] => Fellowship
[1] => 10
[Ident] => 10
[2] => 11021001
[ProjectCode] => 11021001
[3] =>
[Department] =>
[4] => 18
[5] => 25000
[Amount] => 25000
[6] => hghg/2010
[LetterNo] => hghg/2010
[7] => 2010-09-28
[LetterDate] => 2010-09-28
[8] => Fellowship
)
)

)


This array should be formed like this as given below

Array
(
[0] => Array
(
[0] => Array
(
[0] => 11
[BudgetHead] => Contingency
[1] => 1
[Ident] => 1
[2] => 11021001
[ProjectCode] => 11021001
[3] =>
[Department] =>
[4] => 11
[5] => 500
[Amount] => 500
[6] => csir/2010/101
[LetterNo] => csir/2010/101
[7] => 2010-09-27
[LetterDate] => 2010-09-27
[8] => Contingency
)
[1] => Array
(
[0] => 11
[BudgetHead] => Contingency
[1] => 6
[Ident] => 6
[2] => 11021001
[ProjectCode] => 11021001
[3] =>
[Department] =>
[4] => 11
[5] => 5000
[Amount] => 5000
[6] => hghg/2010
[LetterNo] => hghg/2010
[7] => 2010-09-28
[LetterDate] => 2010-09-28
[8] => Contingency
)

[2] => Array
(
[0] => 11
[BudgetHead] => Contingency
[1] => 11
[Ident] => 11
[2] => 11021001
[ProjectCode] => 11021001
[3] =>
[Department] =>
[4] => 11
[5] => 100000
[Amount] => 100000
[6] =>
[LetterNo] =>
[7] => 2010-10-10
[LetterDate] => 2010-10-10
[8] => Contingency
)
)
[1] => Array
(
[0] => Array
(
[0] => 15
[BudgetHead] => Equipment(Major)
[1] => 2
[Ident] => 2
[2] => 11021001
[ProjectCode] => 11021001
[3] =>
[Department] =>
[4] => 15
[5] => 1000
[Amount] => 1000
[6] => csir/2010/101
[LetterNo] => csir/2010/101
[7] => 2010-09-27
[LetterDate] => 2010-09-27
[8] => Equipment(Major)
)
[1] => Array
(
[0] => 15
[BudgetHead] => Equipment(Major)
[1] => 7
[Ident] => 7
[2] => 11021001
[ProjectCode] => 11021001
[3] =>
[Department] =>
[4] => 15
[5] => 10000
[Amount] => 10000
[6] => hghg/2010
[LetterNo] => hghg/2010
[7] => 2010-09-28
[LetterDate] => 2010-09-28
[8] => Equipment(Major)
)
)

[2] => Array
(
[0] => Array
(
[0] => 35
[BudgetHead] => Overhead Charges - Departments
[1] => 3
[Ident] => 3
[2] => 11021001
[ProjectCode] => 11021001
[3] =>
[Department] =>
[4] => 35
[5] => 1500
[Amount] => 1500
[6] => csir/2010/101
[LetterNo] => csir/2010/101
[7] => 2010-09-27
[LetterDate] => 2010-09-27
[8] => Overhead Charges - Departments
)
[1] => Array
(
[0] => 35
[BudgetHead] => Overhead Charges - Departments
[1] => 8
[Ident] => 8
[2] => 11021001
[ProjectCode] => 11021001
[3] =>
[Department] =>
[4] => 35
[5] => 15000
[Amount] => 15000
[6] => hghg/2010
[LetterNo] => hghg/2010
[7] => 2010-09-28
[LetterDate] => 2010-09-28
[8] => Overhead Charges - Departments
)
)
[3] => Array
(
[0] =>Array
(
[0] => 36
[BudgetHead] => Overhead Charges - University
[1] => 4
[Ident] => 4
[2] => 11021001
[ProjectCode] => 11021001
[3] =>
[Department] =>
[4] => 36
[5] => 2000
[Amount] => 2000
[6] => csir/2010/101
[LetterNo] => csir/2010/101
[7] => 2010-09-27
[LetterDate] => 2010-09-27
[8] => Overhead Charges – University
)
[1] => Array
(
[0] => 36
[BudgetHead] => Overhead Charges - University
[1] => 9
[Ident] => 9
[2] => 11021001
[ProjectCode] => 11021001
[3] =>
[Department] =>
[4] => 36
[5] => 20000
[Amount] => 20000
[6] => hghg/2010
[LetterNo] => hghg/2010
[7] => 2010-09-28
[LetterDate] => 2010-09-28
[8] => Overhead Charges - University
)
)

[4] => Array
(
[0] =>Array
(
[0] => 18
[BudgetHead] => Fellowship
[1] => 5
[Ident] => 5
[2] => 11021001
[ProjectCode] => 11021001
[3] =>
[Department] =>
[4] => 18
[5] => 2500
[Amount] => 2500
[6] => csir/2010/101
[LetterNo] => csir/2010/101
[7] => 2010-09-27
[LetterDate] => 2010-09-27
[8] => Fellowship
)
[10] => Array
(
[0] => 18
[BudgetHead] => Fellowship
[1] => 10
[Ident] => 10
[2] => 11021001
[ProjectCode] => 11021001
[3] =>
[Department] =>
[4] => 18
[5] => 25000
[Amount] => 25000
[6] => hghg/2010
[LetterNo] => hghg/2010
[7] => 2010-09-28
[LetterDate] => 2010-09-28
[8] => Fellowship
)
)

)

The concept of this is. i have compared the budgetHead which has same value and it should be formed as single array. I have tried my best but i didnt get any solution. Please any one help me. I need its soon.if any code is available means send it ashraf.y84@gmail.com

There is 1 reply in this thread, which is not being displayed.
Browsing this forum thread replies is available only to premium subscribers.


Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.